'Flutter Web : "Should never encounter KeyData when transitMode is rawKeyData."
When I run my project on web the Exception message and stack trace was
"Should never encounter KeyData when transitMode is rawKeyData."
at Object.throw_ [as throw] (http://localhost:2621/dart_sdk.js:5061:11)
at Object.assertFailed (http://localhost:2621/dart_sdk.js:4986:15)
at hardware_keyboard.KeyEventManager.new.handleKeyData (http://localhost:2621/packages/flutter/src/services/restoration.dart.lib.js:5334:28)
at http://localhost:2621/dart_sdk.js:160131:47
at Object.invoke (http://localhost:2621/dart_sdk.js:179656:7)
at _engine.EnginePlatformDispatcher.__.invokeOnKeyData (http://localhost:2621/dart_sdk.js:160131:17)
at _engine.KeyboardBinding.__.[_onKeyData] (http://localhost:2621/dart_sdk.js:158922:49)
at _engine.KeyboardConverter.new.handleEvent (http://localhost:2621/dart_sdk.js:159210:16)
at http://localhost:2621/dart_sdk.js:158929:74
at loggedHandler (http://localhost:2621/dart_sdk.js:158906:43)
Error: Assertion failed: file:///E:/flutter_windows_2.5.2-stable/flutter/packages/flutter/lib/src/services/hardware_keyboard.dart:787:16
Solution 1:[1]
try one of theies
flutter run -d chrome --web-renderer html
flutter build web --web-renderer html
Solution 2:[2]
If you are getting problem on Device or Emulator or Simulator, Just close the app and Run again.
In my case, I have initialised controller in init
method and I changed something related to controller so its needs to be updated. That's why we need to rerun again.
P.S. I thought to restart the app but doesn't worked for me.
Solution 3:[3]
I am encountering this issue here and there also. I'm getting it while using emulator/simulator on MacOS. This completely kills the app on the simulator, hot-reload does NOT fix this, after hot-reload the app is completely frozen.
The only way for me to fix this is to completely quit simulator & VS Code project. Reload VS Code project and simulator and it works again.
This is a horrible issue & seriously interrupts development & production. Hope it gets fixed soon!
Solution 4:[4]
In my case, it was related to my widgets state which was connected to a GetX controller which was never injected to the widget tree. So it was complaining about the not initialized state with a awkward log.
Solution 5:[5]
just do full re run the application.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | hasanm08 |
Solution 2 | Pratik Butani |
Solution 3 | RobbB |
Solution 4 | Stephen Ostermiller |
Solution 5 | Ritunjay kumar |