Change some usage of RawKeyEvent to KeyEvent in preparation for deprecation (#136420)
## Description This converts some usages of `RawKeyEvent` to `KeyEvent` to prepare the repo for deprecation of `RawKeyEvent`, and swaps out the `raw_keyboard.dart` manual test for `hardware_keyboard.dart`. ## Related Issues - https://github.com/flutter/flutter/issues/136419 ## Tests - Just refactoring code, no semantic changes.
This commit is contained in:
@@ -33,8 +33,8 @@ class FocusExample extends StatefulWidget {
|
||||
class _FocusExampleState extends State<FocusExample> {
|
||||
Color _color = Colors.white;
|
||||
|
||||
KeyEventResult _handleKeyPress(FocusNode node, RawKeyEvent event) {
|
||||
if (event is RawKeyDownEvent) {
|
||||
KeyEventResult _handleKeyPress(FocusNode node, KeyEvent event) {
|
||||
if (event is KeyDownEvent) {
|
||||
debugPrint('Focus node ${node.debugLabel} got key event: ${event.logicalKey}');
|
||||
if (event.logicalKey == LogicalKeyboardKey.keyR) {
|
||||
debugPrint('Changing color to red.');
|
||||
@@ -68,7 +68,7 @@ class _FocusExampleState extends State<FocusExample> {
|
||||
child: DefaultTextStyle(
|
||||
style: textTheme.headlineMedium!,
|
||||
child: Focus(
|
||||
onKey: _handleKeyPress,
|
||||
onKeyEvent: _handleKeyPress,
|
||||
debugLabel: 'Button',
|
||||
child: Builder(
|
||||
builder: (BuildContext context) {
|
||||
|
||||
Reference in New Issue
Block a user