Skip to content

Commit

Permalink
Fix deprecated usage of RawKeyEvent and RawKeyboard (flutter#1063)
Browse files Browse the repository at this point in the history
## Description

This fixes the deprecated usages of `RawKeyEvent` and `RawKeyboard` in the gallery.

## Related Issues
 - flutter/flutter#136419

## Tests
 - No tests needed updating, since it's just a refactor with no semantic changes.
  • Loading branch information
gspencergoog authored and genx7up committed Dec 13, 2023
1 parent 31a1caf commit 519217b
Show file tree
Hide file tree
Showing 4 changed files with 43 additions and 27 deletions.
4 changes: 2 additions & 2 deletions lib/layout/highlight_focus.dart
Original file line number Diff line number Diff line change
Expand Up @@ -78,8 +78,8 @@ class _HighlightFocusState extends State<HighlightFocus> {
isFocused = newValue;
});
},
onKey: (node, event) {
if (event is RawKeyDownEvent &&
onKeyEvent: (node, event) {
if ((event is KeyDownEvent || event is KeyRepeatEvent) &&
(event.logicalKey == LogicalKeyboardKey.space ||
event.logicalKey == LogicalKeyboardKey.enter ||
event.logicalKey == LogicalKeyboardKey.numpadEnter)) {
Expand Down
4 changes: 2 additions & 2 deletions lib/pages/backdrop.dart
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,10 @@ class _BackdropState extends State<Backdrop> with TickerProviderStateMixin {
return ExcludeSemantics(
excluding: !isSettingsOpen,
child: isSettingsOpen
? RawKeyboardListener(
? KeyboardListener(
includeSemantics: false,
focusNode: _settingsPageFocusNode,
onKey: (event) {
onKeyEvent: (event) {
if (event.logicalKey == LogicalKeyboardKey.escape) {
_toggleSettings();
}
Expand Down
4 changes: 2 additions & 2 deletions lib/studies/rally/login.dart
Original file line number Diff line number Diff line change
Expand Up @@ -291,8 +291,8 @@ class _ThumbButtonState extends State<_ThumbButton> {
child: GestureDetector(
onTap: widget.onTap,
child: Focus(
onKey: (node, event) {
if (event is RawKeyDownEvent) {
onKeyEvent: (node, event) {
if (event is KeyDownEvent || event is KeyRepeatEvent) {
if (event.logicalKey == LogicalKeyboardKey.enter ||
event.logicalKey == LogicalKeyboardKey.space) {
widget.onTap();
Expand Down
58 changes: 37 additions & 21 deletions pubspec.lock
Original file line number Diff line number Diff line change
Expand Up @@ -101,10 +101,10 @@ packages:
dependency: transitive
description:
name: coverage
sha256: "2fb815080e44a09b85e0f2ca8a820b15053982b2e714b59267719e8a9ff17097"
sha256: ac86d3abab0f165e4b8f561280ff4e066bceaac83c424dd19f1ae2c2fcd12ca9
url: "https://pub.dev"
source: hosted
version: "1.6.3"
version: "1.7.1"
crypto:
dependency: transitive
description:
Expand Down Expand Up @@ -149,10 +149,10 @@ packages:
dependency: transitive
description:
name: file
sha256: "1b92bec4fc2a72f59a8e15af5f52cd441e4a7860b49499d69dfa817af20e925d"
sha256: "5fc22d7c25582e38ad9a8515372cd9a93834027aacf1801cf01164dac0ffa08c"
url: "https://pub.dev"
source: hosted
version: "6.1.4"
version: "7.0.0"
flutter:
dependency: "direct main"
description: flutter
Expand Down Expand Up @@ -311,6 +311,22 @@ packages:
url: "https://pub.dev"
source: hosted
version: "0.6.7"
leak_tracker:
dependency: transitive
description:
name: leak_tracker
sha256: "04be76c4a4bb50f14904e64749237e541e7c7bcf7ec0b196907322ab5d2fc739"
url: "https://pub.dev"
source: hosted
version: "9.0.16"
leak_tracker_testing:
dependency: transitive
description:
name: leak_tracker_testing
sha256: b06739349ec2477e943055aea30172c5c7000225f79dad4702e2ec0eda79a6ff
url: "https://pub.dev"
source: hosted
version: "1.0.5"
lints:
dependency: transitive
description:
Expand Down Expand Up @@ -339,18 +355,18 @@ packages:
dependency: transitive
description:
name: material_color_utilities
sha256: "9528f2f296073ff54cb9fee677df673ace1218163c3bc7628093e7eed5203d41"
sha256: "0e0a020085b65b6083975e499759762399b4475f766c21668c4ecca34ea74e5a"
url: "https://pub.dev"
source: hosted
version: "0.5.0"
version: "0.8.0"
meta:
dependency: "direct main"
description:
name: meta
sha256: a6e590c838b18133bb482a2745ad77c5bb7715fb0451209e1a7567d416678b8e
sha256: d584fa6707a52763a52446f02cc621b077888fb63b93bbcb1143a7be5a0c0c04
url: "https://pub.dev"
source: hosted
version: "1.10.0"
version: "1.11.0"
mime:
dependency: transitive
description:
Expand Down Expand Up @@ -387,10 +403,10 @@ packages:
dependency: "direct dev"
description:
name: path
sha256: "8829d8a55c13fc0e37127c29fedf290c102f4e40ae94ada574091fe0ff96c917"
sha256: "087ce49c3f0dc39180befefc60fdb4acd8f8620e5682fe2476afd0b3688bb4af"
url: "https://pub.dev"
source: hosted
version: "1.8.3"
version: "1.9.0"
path_provider:
dependency: transitive
description:
Expand Down Expand Up @@ -443,10 +459,10 @@ packages:
dependency: transitive
description:
name: platform
sha256: ae68c7bfcd7383af3629daafb32fb4e8681c7154428da4febcff06200585f102
sha256: "0a279f0707af40c890e80b1e9df8bb761694c074ba7e1d4ab1bc4b728e200b59"
url: "https://pub.dev"
source: hosted
version: "3.1.2"
version: "3.1.3"
plugin_platform_interface:
dependency: transitive
description:
Expand All @@ -467,10 +483,10 @@ packages:
dependency: transitive
description:
name: process
sha256: "53fd8db9cec1d37b0574e12f07520d582019cb6c44abf5479a01505099a34a09"
sha256: "266ca5be5820feefc777793d0a583acfc8c40834893c87c00c6c09e2cf58ea42"
url: "https://pub.dev"
source: hosted
version: "4.2.4"
version: "5.0.1"
provider:
dependency: "direct main"
description:
Expand Down Expand Up @@ -728,10 +744,10 @@ packages:
dependency: transitive
description:
name: vm_service
sha256: c538be99af830f478718b51630ec1b6bee5e74e52c8a802d328d9e71d35d2583
sha256: b3d56ff4341b8f182b96aceb2fa20e3dcb336b9f867bc0eafc0de10f1048e957
url: "https://pub.dev"
source: hosted
version: "11.10.0"
version: "13.0.0"
watcher:
dependency: transitive
description:
Expand All @@ -744,10 +760,10 @@ packages:
dependency: transitive
description:
name: web
sha256: afe077240a270dcfd2aafe77602b4113645af95d0ad31128cc02bce5ac5d5152
sha256: edc8a9573dd8c5a83a183dae1af2b6fd4131377404706ca4e5420474784906fa
url: "https://pub.dev"
source: hosted
version: "0.3.0"
version: "0.4.0"
web_benchmarks:
dependency: "direct dev"
description:
Expand All @@ -768,10 +784,10 @@ packages:
dependency: transitive
description:
name: webdriver
sha256: "3c923e918918feeb90c4c9fdf1fe39220fa4c0e8e2c0fffaded174498ef86c49"
sha256: "003d7da9519e1e5f329422b36c4dcdf18d7d2978d1ba099ea4e45ba490ed845e"
url: "https://pub.dev"
source: hosted
version: "3.0.2"
version: "3.0.3"
webkit_inspection_protocol:
dependency: transitive
description:
Expand Down Expand Up @@ -805,5 +821,5 @@ packages:
source: hosted
version: "3.1.2"
sdks:
dart: ">=3.1.0 <4.0.0"
dart: ">=3.2.0-194.0.dev <4.0.0"
flutter: ">=3.13.0"

0 comments on commit 519217b

Please sign in to comment.