【Flutter】A KeyUpEvent is dispatched, but the state shows that the physical key is not pressed.

2022/10/19 23:39

Error message

[ERROR:flutter/runtime/dart_vm_initializer.cc(41)] Unhandled Exception: ‘package:flutter/src/services/hardware_keyboard.dart’: Failed assertion: line 432 pos 16:

_pressedKeys.containsKey(event.physicalKey)’: A KeyUpEvent is dispatched, but the state shows that the physical key is not 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:

KeyUpEvent#8d8cc(physicalKey: PhysicalKeyboardKey#7002a(usbHidUsage: “0x0007002a”, debugName: “Backspace”), logicalKey: LogicalKeyboardKey#00008(keyId: “0x100000008”, keyLabel: “Backspace”, debugName: “Backspace”), character: null, timeStamp: 0:08:08.070741, synthesized)

E/flutter (23482): #0 _AssertionError._doThrowNew (dart:core-patch/errors_patch.dart:51:61)

E/flutter (23482): #1 _AssertionError._throwNew (dart:core-patch/errors_patch.dart:40:5)

E/flutter (23482): #2 HardwareKeyboard._assertEventIsRegular.<anonymous closure> (package:flutter/src/services/hardware_keyboard.dart:432:16)

E/flutter (23482): #3 HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:443:6)

E/flutter (23482): #4 HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:535:5)

E/flutter (23482): #5 KeyEventManager.handleKeyData (package:flutter/src/services/hardware_keyboard.dart:808:29)

E/flutter (23482): #6 PlatformDispatcher._keyDataListener.<anonymous closure>.<anonymous closure> (dart:ui/platform_dispatcher.dart:410:41)

Solution

Check your keybaord configuration. “the physical key is not pressed” shows us the answer.

Leave a Reply

Back to top