-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Update key examples to use Focus widgets instead of RawKeyboardListener
#101537
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
dkwingsmt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A few comments, see if you'd like to address.
| /// keyboard events. | ||
| /// * [Focus.onKey], the handler on a widget that lets you handle key events. | ||
| /// * [RawKeyboardListener], a widget used to listen to keyboard events (but | ||
| /// not handle them). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
| /// not handle them). | |
| /// can not affect how the event are handled by other widgets). |
| await tester.tap(find.text('Click to focus')); | ||
| await tester.pumpAndSettle(); | ||
| expect(find.text('Press a key'), findsOneWidget); | ||
| // Yes, this is a physical keyboard key test, but we don't have a way to |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We actually do. The global simulateKeyUpEvent supports a physicalKey named parameter, which is not exposed by tester.sendKeyEvent (and probably should.)
dkwingsmt
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Description
This updates the examples for
PhysicalKeyboardKeyandLogicalKeyboardKeyto useFocuswidgets that handle the keys instead of usingRawKeyboardListener, since that usually leads people down the wrong path. Updated the See Also and added tests as well.Related Issues
Tests