flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
162.18k stars 26.64k forks source link

Keys appear "stuck" after pressing Meta key in conjunction with other keys #147410

Open khoadng opened 2 weeks ago

khoadng commented 2 weeks ago

Steps to reproduce

  1. Run sample code on iOS simulator
  2. Press and hold Meta key
  3. Press and hold X (While holding Meta key)
  4. Press and hold Z (While holding Meta key and X key)
  5. Release both X and Z keys (While holding Meta key)
  6. Release Meta key
  7. Pressing any keys

Expected results

No key got stuck

Actual results

X and Z keys appear "stuck" even though they are already released on physical keyboard.

Code sample

Code sample ```dart import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; void main() { runApp(const App()); } class App extends StatelessWidget { const App({ super.key, }); @override Widget build(BuildContext context) { return const MaterialApp( home: SamplePage(), ); } } class SamplePage extends StatefulWidget { const SamplePage({super.key}); @override State createState() => _SamplePageState(); } class _SamplePageState extends State { String log = ''; @override void initState() { super.initState(); HardwareKeyboard.instance.addHandler(_handleKeyEvent); } bool _handleKeyEvent(KeyEvent event) { setState(() { log = HardwareKeyboard.instance.logicalKeysPressed .map((e) => e.debugName) .join('\n'); }); return false; } @override void dispose() { super.dispose(); HardwareKeyboard.instance.removeHandler(_handleKeyEvent); } @override Widget build(BuildContext context) { return Scaffold( body: SafeArea( child: Container( padding: const EdgeInsets.all(32), child: Column( mainAxisAlignment: MainAxisAlignment.center, children: [ Text('Pressed keys:'), Text(log), ], ), ), ), ); } } ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here] https://github.com/flutter/flutter/assets/19619099/50c91736-f037-414f-bee1-a8b020b53b04

Logs

Logs ```console [Paste your logs here] ```

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.19.5, on macOS 14.4.1 23E224 darwin-arm64, locale en-VN) • Flutter version 3.19.5 on channel stable at /Users/khoa/SDK/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 300451adae (4 weeks ago), 2024-03-27 21:54:07 -0500 • Engine revision e76c956498 • Dart version 3.3.3 • DevTools version 2.31.1 [✓] Android toolchain - develop for Android devices (Android SDK version 33.0.0) • Android SDK at /Users/khoa/Library/Android/sdk • Platform android-34, build-tools 33.0.0 • Java binary at: /Users/khoa/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.11090377/Android Studio.app/Contents/jbr/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 15.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 15E204a • CocoaPods version 1.14.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 2022.1) • Android Studio at /Users/khoa/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/221.6008.13.2211.9619390/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 11.0.15+0-b2043.56-8887301) [✓] Android Studio (version 2022.3) • Android Studio at /Users/khoa/Library/Application Support/JetBrains/Toolbox/apps/AndroidStudio/ch-0/223.8836.35.2231.11090377/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b829.9-10027231) [✓] VS Code (version 1.88.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.86.0 [✓] Connected device (4 available) • 2109119DG (mobile) • adb-6b2da568-RvlFYv._adb-tls-connect._tcp. • android-arm64 • Android 13 (API 33) • iPhone 15 Pro Max (mobile) • C18B879E-A687-4876-A901-8712C59EAECB • ios • com.apple.CoreSimulator.SimRuntime.iOS-17-4 (simulator) • macOS (desktop) • macos • darwin-arm64 • macOS 14.4.1 23E224 darwin-arm64 • Chrome (web) • chrome • web-javascript • Google Chrome 124.0.6367.62 [✓] Network resources • All expected network resources are available. • No issues found! ```
darshankawar commented 2 weeks ago

Thanks for the report @khoadng Although I do see the same behavior in stable version, but not in latest master as shown below:

https://github.com/flutter/flutter/assets/67046386/77f92d63-0038-4352-a4e5-b19172e7dde2

Please check the same at your end by switching to latest master and re-running your scenario.

I verified master on Channel master, 3.22.0-18.0.pre.53