Repository navigation
Null check operator used on a null _rawKeyboard.lookUpLayout(physicalKey)! #88236
Copy link
Copy link
Closed
Labels
a: null-safetySupport for Dart's null safety featureSupport for Dart's null safety featurea: productionIssues experienced in live production appsIssues experienced in live production appsa: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowIt was better in the past than it is nowframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.platform-androidAndroid applications specificallyAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
Sorry I cannot reproduce it, it is collected from a small amount of app users' crash feedback. All are android devices.
Error:
Null check operator used on a null value
Stack trace:
#0 KeyEventManager._convertRawEventAndStore (package:flutter/src/services/hardware_keyboard.dart:892)
#1 RawKeyboard.handleRawKeyEvent (package:flutter/src/services/raw_keyboard.dart:677)
#2 KeyEventManager.handleRawKeyMessage (package:flutter/src/services/hardware_keyboard.dart:818)
#3 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:73)
#4 BasicMessageChannel.setMessageHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:72)
#5 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:379)
#6 _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:376)
#7 _invoke2.<anonymous closure> (dart:ui/hooks.dart:205)
#8 _rootRun (dart:async/zone.dart:1428)
#9 _CustomZone.run (dart:async/zone.dart:1328)
#10 _CustomZone.runGuarded (dart:async/zone.dart:1236)
#11 _invoke2 (dart:ui/hooks.dart:204)
#12 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42)
#13 _Channel.push (dart:ui/channel_buffers.dart:132)
#14 ChannelBuffers.push (dart:ui/channel_buffers.dart:329)
#15 PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:544)
#16 _dispatchPlatformMessage (dart:ui/hooks.dart:92)
flutter/packages/flutter/lib/src/services/hardware_keyboard.dart
Lines 889 to 896 in 338ade8
| for (final PhysicalKeyboardKey key in _rawKeyboard.physicalKeysPressed.difference(physicalKeysPressed)) { | |
| _keyEventsSinceLastMessage.add(KeyDownEvent( | |
| physicalKey: key, | |
| logicalKey: _rawKeyboard.lookUpLayout(physicalKey)!, | |
| timeStamp: timeStamp, | |
| synthesized: true, | |
| )); | |
| } |
Built using Flutter (Channel beta, 2.5.0-5.1.pre, on Microsoft Windows [Version 10.0.19043.1110], locale zh-CN)
flutter doctor -v
[✓] Flutter (Channel beta, 2.5.0-5.1.pre, on Microsoft Windows [Version 10.0.19043.1110], locale zh-CN)
• Flutter version 2.5.0-5.1.pre at D:\Projects\sdk\flutter
• Upstream repository https://mirrors.tuna.tsinghua.edu.cn/git/flutter-sdk.git
• Framework revision 65cf7de5f4 (3 days ago), 2021-08-11 15:48:01 -0700
• Engine revision fbeb7e22bd
• Dart version 2.14.0 (build 2.14.0-377.4.beta)
• 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 30.0.3)
• Android SDK at D:\Projects\sdk\Android\Sdk
• Platform android-30, build-tools 30.0.3
• ANDROID_HOME = D:\Projects\sdk\Android\Sdk
• Java binary at: C:\Users\narumi\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-1\202.7486908\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
• All Android licenses accepted.
[✗] Chrome - develop for the web (Cannot find Chrome executable at .\Google\Chrome\Application\chrome.exe)
! Cannot find Chrome. Try setting CHROME_EXECUTABLE to a Chrome executable.
[✓] Visual Studio - develop for Windows (Visual Studio Enterprise 2019 16.8.3)
• Visual Studio at C:\Program Files (x86)\Microsoft Visual Studio\2019\Enterprise
• Visual Studio Enterprise 2019 version 16.8.30804.86
• Windows 10 SDK version 10.0.18362.0
[✓] Android Studio (version 4.2)
• Android Studio at C:\Users\narumi\AppData\Local\JetBrains\Toolbox\apps\AndroidStudio\ch-1\202.7486908
• Flutter plugin version 59.0.1
• Dart plugin version 202.8531
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6842174)
[✓] VS Code (version 1.57.1)
• VS Code at C:\Users\narumi\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.24.0
[✓] Connected device (2 available)
• Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19043.1110]
• Edge (web) • edge • web-javascript • Microsoft Edge 92.0.902.62
! Doctor found issues in 1 category.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a: null-safetySupport for Dart's null safety featureSupport for Dart's null safety featurea: productionIssues experienced in live production appsIssues experienced in live production appsa: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsc: regressionIt was better in the past than it is nowIt was better in the past than it is nowframeworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.platform-androidAndroid applications specificallyAndroid applications specificallyr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Activity
[-]Null check operator used on a null value[/-][+]KeyEventManager._convertRawEventAndStore: Null check operator used on a null `_rawKeyboard.lookUpLayout(physicalKey)!`[/+]TahaTesser commentedon Aug 17, 2021
Hi @narumishi
Can you please provide your
pubspec.yaml, the list of affected devices and if possible yourflutter run --release --verboserunning on the same OS version as the affected devices.Thank you
narumi147 commentedon Aug 17, 2021
@TahaTesser You can check
pubspec.yamlandpubspec.lockhere: https://github.com/chaldea-center/chaldea/blob/21b308555fc3ad507df0ffd645343b072e478f61/pubspec.yamlThe problem is occurred just in
flutter beta, 2.5.0-5.1.pre, I didn't receive any report of this built by2.4.0-4.1.pre.I cannot reproduce the problem on my own android device and even don't how to reproduce it. The only thing I know is that users are inputing text......
Every day, about 5 crash reports received while near 800 active devices in total.
some devices
stuartmorgan-g commentedon Aug 19, 2021
@dkwingsmt This looks like code you added recently?
4 remaining items
dkwingsmt commentedon Aug 20, 2021
I can't think of any case that the result of
lookUpLayoutcan be null here, sincephysicalKeysPressedhas literally just ensured that the key's pressed. Let me know if you can come up with a reproduction step. In the meantime I'll raise the priority for the keyboard embedding for Android, after which this should no longer be a problem.narumi147 commentedon Aug 21, 2021
Another similar issue I encountered when developing. See the error below. The error is sometimes raised suddenly(which means I can't reproduce it), and then every keyboard input will raise the same error. I need to hot-restart to fix it.
I'm not sure this is related or not. It's on macOS.
flutter doctor -v
valtbarbos commentedon Aug 21, 2021
There are some ways to reproduce in some environments.
Using an android device via USB with scrcpy (https://github.com/Genymobile/scrcpy).
Using the computer keyboard (don't happens using the android keyboard with mouse) on the TextFormField will throw "Another exception was thrown: Null check operator used on a null value".
dkwingsmt commentedon Aug 27, 2021
For anyone who can reproduce this issue, can you check if #88967 fixes the issue?
dkwingsmt commentedon Aug 31, 2021
Considering this issue fixed via #88967. Feel free to report and/or reopen if similar issues occur.
jmagman commentedon Sep 13, 2021
Adding cp request label for evaluation, requested by @untp in #89913.
silvinhodev commentedon Sep 15, 2021
Hi, here this issue is evident when using a notebook keyboard, after applying fixes, working flawless! (no more issues)
flutter doctor -v
ajaysanity commentedon Sep 24, 2021
We have the same issue. I fixed it by changing the physicalKey to key
mikeesouth commentedon Sep 25, 2021
This bug broke my app completely on Chromebooks with physical keyboard when upgrading to Flutter 2.5.0. After upgrading to Flutter 2.5.1 it works much better but right shift and right control on the Chromebook still causes the same exception. I'm not sure why right shift/control throws this exception but left shift and left control works without exception. Other modifiers and special keys like alt, alt gr, tab, esc, media controls, backspace, dash, comma etc. does not cause the bug but right shift and right control does? Very strange.
I can reproduce this with these simple steps:
flutter create buggy_right_shift_chromebookTextFormField(), e.g. on line 105 under the counter text widget in the exampleI reproduced this on flutter stable 2.5.1 and beta channel (2.6.0-5.2.pre) - same result in both cases. I tried master channel too (2.6.0-12.0.pre.89) but same result there. I'm reproducing it on a Chromebook from HP, model "HP Chromebook - 14-db0004no" (link to specs here). The Chromebook runs ChromeOS 96.0.4648.0, 64 bit.
Any ideas on something that I may be missing?
_CastError
════════ Exception caught by services library ══════════════════════════════════
The following _CastError was thrown during a platform message callback:
Null check operator used on a null value
When the exception was thrown, this was the stack
#0 KeyEventManager._convertRawEventAndStore
package:flutter/…/services/hardware_keyboard.dart:884
#1 RawKeyboard.handleRawKeyEvent
package:flutter/…/services/raw_keyboard.dart:677
#2 KeyEventManager.handleRawKeyMessage
package:flutter/…/services/hardware_keyboard.dart:818
#3 BasicMessageChannel.setMessageHandler.
package:flutter/…/services/platform_channel.dart:73
#4 BasicMessageChannel.setMessageHandler.
package:flutter/…/services/platform_channel.dart:72
#5 _DefaultBinaryMessenger.setMessageHandler.
package:flutter/…/services/binding.dart:379
#6 _DefaultBinaryMessenger.setMessageHandler.
package:flutter/…/services/binding.dart:376
#7 _invoke2. (dart:ui/hooks.dart:205:15)
#11 _invoke2 (dart:ui/hooks.dart:204:10)
#12 _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:42:5)
flutter doctor -v
[√] Flutter (Channel stable, 2.5.1, on Microsoft Windows [Version 10.0.19041.1237], locale sv-SE)
• Flutter version 2.5.1 at C:\Stuff\flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision ffb2ece (8 days ago), 2021-09-17 15:26:33 -0400
• Engine revision b3af521a05
• Dart version 2.14.2
[√] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
• Android SDK at C:\Users\Micke\AppData\Local\Android\sdk
• Platform android-30, build-tools 30.0.2
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 11.0.10+0-b96-7249189)
• All Android licenses accepted.
[√] Chrome - develop for the web
• Chrome at C:\Program Files (x86)\Google\Chrome\Application\chrome.exe
[√] Android Studio (version 2020.3)
• Android Studio at C:\Program Files\Android\Android Studio
• 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.10+0-b96-7249189)
[√] VS Code (version 1.60.2)
• VS Code at C:\Users\Micke\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.26.0
[√] Connected device (4 available)
• grunt (mobile) • 192.168.86.47:5555 • android-x64 • Android 9 (API 28)
• Android SDK built for x86 (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 92.0.4515.159
• Edge (web) • edge • web-javascript • Microsoft Edge 93.0.961.47
• No issues found!
github-actions commentedon Oct 10, 2021
This thread has been automatically locked since there has not been any recent activity after it was closed. If you are still experiencing a similar issue, please open a new bug, including the output of
flutter doctor -vand a minimal reproduction of the issue.