Search code examples
flutterflutter-windowsflutter-textinputfield

Flutter for Windows - A KeyRepeatEvent is dispatched, but the state shows that the physical key is not pressed - Shift Left


I'm building a Flutter Application for Windows. I have a TextField and if I run the Application and want to insert an uppercase Character by holding Shift Left or Shift Right and than a letter, I get the following Error:

The following assertion was thrown during a platform message callback:   
A KeyRepeatEvent 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: KeyRepeatEvent#d843e(physicalKey: PhysicalKeyboardKey#700e1(usbHidUsage: "0x000700e1", debugName: "Shift Left"), logicalKey: LogicalKeyboardKey#00102(keyId: "0x200000102", keyLabel: "Shift Left", debugName: "Shift Left"), character: null, timeStamp: 124:45:14.849439)   
'package:flutter/src/services/hardware_keyboard.dart':   
Failed assertion: line 432 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:432:16)   
#3      HardwareKeyboard._assertEventIsRegular (package:flutter/src/services/hardware_keyboard.dart:443:6)   
#4      HardwareKeyboard.handleKeyEvent (package:flutter/src/services/hardware_keyboard.dart:535:5)   
#5      KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:881:37)   
#6      BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:197:49)   
#7      _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:387:35)   
#8      _invoke2 (dart:ui/hooks.dart:186:13)   
#9      _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)   
#10     _Channel.push (dart:ui/channel_buffers.dart:132:31)   
#11     ChannelBuffers.push (dart:ui/channel_buffers.dart:329:17)   
#12     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:599:22)   
#13     _dispatchPlatformMessage (dart:ui/hooks.dart:89:31)   
(elided 2 frames from class _AssertionError)   

By pressing Caps Lock and than a letter, I don't get this error. It seems like Flutter can't handle the combination of Shift and a letter.

Does someone know why that it is? And how to solve that?

My Flutter setup:

Flutter 3.3.4 • channel stable • https://github.com/flutter/flutter.git   
Framework • revision eb6d86ee27 (13 days ago) • 2022-10-04 22:31:45 -0700   
Engine • revision c08d7d5efc   
Tools • Dart 2.18.2 • DevTools 2.15.0   

Running flutter doctor...   
Doctor summary (to see all details, run flutter doctor -v):   
[√] Flutter (Channel stable, 3.3.4, on Microsoft Windows [Version 10.0.19044.2130], locale de-DE)   
[√] Android toolchain - develop for Android devices (Android SDK version 32.1.0-rc1)   
[√] Chrome - develop for the web   
[√] Visual Studio - develop for Windows (Visual Studio Community 2022 17.3.6)   
[√] Android Studio (version 2021.2)   
[√] VS Code (version 1.71.2)   
[√] Connected device (3 available)   
[√] HTTP Host Availability   
   
• No issues found!   

Solution

  • Okay, I was reading in some other Forums and Git Issues that that is fixed on the master channel. So I switched from stable channel to master channel and I don't get this error any more.

    To do that you have to run:

    flutter channel master
    flutter upgrade