Steps to Reproduce
- Execute flutter run on the code sample
- Connect to bluetooth keyboard on Android device.
- Press alt+tab
Expected results:
When back to the app, it should be able to input text.
Actual results:
Can not input anything.
Code sample
import 'package:flutter/material.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({Key? key}) : super(key: key);
// This widget is the root of your application.
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Flutter Demo',
home: const KeyboardIssue(),
);
}
}
class KeyboardIssue extends StatelessWidget {
const KeyboardIssue({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return Scaffold(body: Center(child: TextField()));
}
}
Logs
[+21701 ms] D/InputMethodManager(31956): showSoftInput() view=io.flutter.embedding.android.FlutterView{a1b3a90 VFE...... .F....ID 0,0-1440,3064 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
[ +9 ms] W/IInputConnectionWrapper(31956): beginBatchEdit on inactive InputConnection
[ ] W/IInputConnectionWrapper(31956): getTextBeforeCursor on inactive InputConnection
[ +6 ms] W/IInputConnectionWrapper(31956): getTextAfterCursor on inactive InputConnection
[ ] W/IInputConnectionWrapper(31956): getSelectedText on inactive InputConnection
[ ] W/IInputConnectionWrapper(31956): endBatchEdit on inactive InputConnection
[ +40 ms] D/InsetsController(31956): show(ime(), fromIme=true)
[ +77 ms] D/InsetsController(31956): show(ime(), fromIme=true)
======== Exception caught by services library ======================================================
The following assertion was thrown during a platform message callback:
A KeyDownEvent is dispatched, but the state shows that the physical key is already pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyDownEvent#71bc1(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 227:30:13.472758, synthesized)
'package:flutter/src/services/hardware_keyboard.dart':
Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)'
Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
https://github.com/flutter/flutter/issues/new?template=2_bug.md
When the exception was thrown, this was the stack:
#2 HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:437:16)
#3 HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:452:6)
#4 HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:543:5)
#5 KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:821:35)
#6 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:73:49)
#7 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:72:47)
#8 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:379:35)
#9 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:376:46)
#10 _invoke2.<anonymous closure> (dart:ui/hooks.dart:205:15)
#14 _invoke2 (dart:ui/hooks.dart:204:10)
#15 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
#16 _Channel.push (dart:ui/channel_buffers.dart:132:31)
#17 ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)
#18 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:544:22)
#19 _dispatchPlatformMessage (dart:ui/hooks.dart:92:31)
(elided 5 frames from class _AssertionError and dart:async)
====================================================================================================
[✓] Flutter (Channel stable, 2.5.3, on Manjaro Linux 5.10.79-1-MANJARO, locale zh_CN.UTF-8)
• Flutter version 2.5.3 at /home/darren/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 18116933e7 (7 周前), 2021-10-15 10:46:35 -0700
• Engine revision d3ea636dc5
• Dart version 2.14.4
• Pub download mirror https://pub.flutter-io.cn
• Flutter download mirror https://storage.flutter-io.cn
[✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0)
• Android SDK at /home/darren/Android/Sdk
• Platform android-31, build-tools 31.0.0
• ANDROID_SDK_ROOT = /home/darren/Android/Sdk
• Java binary at: /opt/android-studio/jre/bin/java
• Java version openjdk version "11.0.10" 2021-01-19
• All Android licenses accepted.
[✓] Chrome - develop for the web
• CHROME_EXECUTABLE = /usr/bin/google-chrome-stable
[✓] Linux toolchain - develop for Linux desktop
• clang version 13.0.0
• cmake version 3.21.4
• ninja version 1.10.2
• pkg-config version 1.8.0
[✓] Android Studio (version 2020.3)
• Android Studio at /opt/android-studio
• Flutter plugin version 62.0.1
• Dart plugin version 203.8452
• Java version openjdk version "11.0.10" 2021-01-19
[✓] Connected device (3 available)
• Pixel 6 Pro (mobile) • 19051FDEE001RV • android-arm64 • Android 12 (API 31)
• Linux (desktop) • linux • linux-x64 • Manjaro Linux 5.10.79-1-MANJARO
• Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.45
• No issues found!
Reactions are currently unavailable
Steps to Reproduce
Expected results:
When back to the app, it should be able to input text.
Actual results:
Can not input anything.
Code sample[+21701 ms] D/InputMethodManager(31956): showSoftInput() view=io.flutter.embedding.android.FlutterView{a1b3a90 VFE...... .F....ID 0,0-1440,3064 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT [ +9 ms] W/IInputConnectionWrapper(31956): beginBatchEdit on inactive InputConnection [ ] W/IInputConnectionWrapper(31956): getTextBeforeCursor on inactive InputConnection [ +6 ms] W/IInputConnectionWrapper(31956): getTextAfterCursor on inactive InputConnection [ ] W/IInputConnectionWrapper(31956): getSelectedText on inactive InputConnection [ ] W/IInputConnectionWrapper(31956): endBatchEdit on inactive InputConnection [ +40 ms] D/InsetsController(31956): show(ime(), fromIme=true) [ +77 ms] D/InsetsController(31956): show(ime(), fromIme=true) ======== Exception caught by services library ====================================================== The following assertion was thrown during a platform message callback: A KeyDownEvent is dispatched, but the state shows that the physical key is already pressed. If this occurs in real application, please report this bug to Flutter. If this occurs in unit tests, please ensure that simulated events follow Flutter's event model as documented in `HardwareKeyboard`. This was the event: KeyDownEvent#71bc1(physicalKey: PhysicalKeyboardKey#700e2(usbHidUsage: "0x000700e2", debugName: "Alt Left"), logicalKey: LogicalKeyboardKey#00104(keyId: "0x200000104", keyLabel: "Alt Left", debugName: "Alt Left"), character: null, timeStamp: 227:30:13.472758, synthesized) 'package:flutter/src/services/hardware_keyboard.dart': Failed assertion: line 437 pos 16: '!_pressedKeys.containsKey(event.physicalKey)' Either the assertion indicates an error in the framework itself, or we should provide substantially more information in this error message to help you determine and fix the underlying cause. In either case, please report this assertion by filing a bug on GitHub: https://github.com/flutter/flutter/issues/new?template=2_bug.md When the exception was thrown, this was the stack: #2 HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:437:16) #3 HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:452:6) #4 HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:543:5) #5 KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:821:35) #6 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:73:49) #7 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:72:47) #8 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:379:35) #9 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:376:46) #10 _invoke2.<anonymous closure> (dart:ui/hooks.dart:205:15) #14 _invoke2 (dart:ui/hooks.dart:204:10) #15 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5) #16 _Channel.push (dart:ui/channel_buffers.dart:132:31) #17 ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17) #18 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:544:22) #19 _dispatchPlatformMessage (dart:ui/hooks.dart:92:31) (elided 5 frames from class _AssertionError and dart:async) ====================================================================================================[✓] Flutter (Channel stable, 2.5.3, on Manjaro Linux 5.10.79-1-MANJARO, locale zh_CN.UTF-8) • Flutter version 2.5.3 at /home/darren/flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision 18116933e7 (7 周前), 2021-10-15 10:46:35 -0700 • Engine revision d3ea636dc5 • Dart version 2.14.4 • Pub download mirror https://pub.flutter-io.cn • Flutter download mirror https://storage.flutter-io.cn [✓] Android toolchain - develop for Android devices (Android SDK version 31.0.0) • Android SDK at /home/darren/Android/Sdk • Platform android-31, build-tools 31.0.0 • ANDROID_SDK_ROOT = /home/darren/Android/Sdk • Java binary at: /opt/android-studio/jre/bin/java • Java version openjdk version "11.0.10" 2021-01-19 • All Android licenses accepted. [✓] Chrome - develop for the web • CHROME_EXECUTABLE = /usr/bin/google-chrome-stable [✓] Linux toolchain - develop for Linux desktop • clang version 13.0.0 • cmake version 3.21.4 • ninja version 1.10.2 • pkg-config version 1.8.0 [✓] Android Studio (version 2020.3) • Android Studio at /opt/android-studio • Flutter plugin version 62.0.1 • Dart plugin version 203.8452 • Java version openjdk version "11.0.10" 2021-01-19 [✓] Connected device (3 available) • Pixel 6 Pro (mobile) • 19051FDEE001RV • android-arm64 • Android 12 (API 31) • Linux (desktop) • linux • linux-x64 • Manjaro Linux 5.10.79-1-MANJARO • Chrome (web) • chrome • web-javascript • Google Chrome 96.0.4664.45 • No issues found!