Repository navigation
Flutter OnScreen Keyboard opens on physical key press #51478
Description
I have a device that uses a laserscanner to scan barcodes and outputs the result as simulated keypresses. I've used this with a RawKeyboardListener and it worked fine. Since then I've added a login screen to the app, that is only shown if the user hasn't logged in. If the login screen has been shown and disposed the onscreen keyboard opens when i press the physical scanner button. This should not happen and doesn't happen if the login screen hasn't been shown. My guess is, that there still are some remains of the textfields used in the login screen, after it is disposed. I've tried setting the FocusNodes for the Textfields and then disposing them in the dispose method, but that didn't work
I've asked a question on StackOverflow: https://stackoverflow.com/questions/60417173/flutter-onscreen-keyboard-opens-on-physical-key-press
Steps to Reproduce
- Screen with one or more Textfields
- focus one or more
- navigate to new screen
- press physical button
Expected results: button is pressed but only the keyevents are fired
Actual results: the onscreen keyboard opens
Logs
[√] Flutter (Channel stable, v1.12.13+hotfix.8, on Microsoft Windows [Version 10.0.16299.1686], locale de-DE)
• Flutter version 1.12.13+hotfix.8 at C:\Users\sruettge\Documents\flutter
• Framework revision 0b8abb4724 (2 weeks ago), 2020-02-11 11:44:36 -0800
• Engine revision e1e6ced81d
• Dart version 2.7.0
[√] Android toolchain - develop for Android devices (Android SDK version 29.0.1)
• Android SDK at C:\Users\sruettge\AppData\Local\Android\sdk
• Android NDK location not configured (optional; useful for native profiling support)
• Platform android-29, build-tools 29.0.1
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
• All Android licenses accepted.
[√] Android Studio (version 3.5)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 36.0.1
• Dart plugin version 183.6270
• Java version OpenJDK Runtime Environment (build 1.8.0_202-release-1483-b03)
[√] VS Code (version 1.42.1)
• VS Code at C:\Users\sruettge\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.8.1
[√] Connected device (1 available)
• MEMOR 10 • S19H00332 • android-arm64 • Android 8.1.0 (API 27)
• No issues found!
Activity
artemtkachenko commentedon Apr 14, 2020
Same issue
I am really disappointed since it blocks flutter development for android applications that have a virtual keyboard but does not have a touch screen.
It is not a rare case, it is a large market of android tv applications.
darshankawar commentedon Aug 25, 2020
Hi @SebastianRuettger,
Can you please confirm if you still experience the issue on latest Stable version ?
Thanks.
SebastianRuettger commentedon Aug 25, 2020
Guillaume-Fortin commentedon Sep 4, 2020
i have same problem with flutter 1.17.5.
i will test on 1.20.3
Guillaume-Fortin commentedon Sep 7, 2020
I have migrate to flutter 1.20.3 and the problem still present on android.
I have a home screen and when i scan with a barcode device plugged with phone, the keyboard keep open after navigation or after dismiss a previous screen keyboard.
For resolve the problem, i need back and return to application on android with application manager.
The used device => Unitech PA760
Guillaume-Fortin commentedon Sep 7, 2020
I debuged.
The method TextInputPlugin.getLastInputConnection keep a reference to an old lastInputConnection when the bug is produced.
When i resume application, the lastInputConnection property begin null and the keyevent work.
CyrilHu commentedon Oct 14, 2020
i have same problem with flutter 1.22.1
nrutledge commentedon Nov 20, 2020
I've just encountered this in Flutter 1.22.4. This is a major problem for any apps integrated with external input devices like barcode scanners.
Has anyone found a suitable workaround that can be used until this is resolved? Currently, I'm resorting to hiding the keyboard after each scan but it causes the keyboard to flash on screen each time which is jarring.
UPDATE: Originally I was testing with the Android emulator. I've just tested now with two physical devices and cannot reproduce on those as of yet.
pkotowski commentedon Dec 10, 2020
Same issue:
[√] Flutter (Channel stable, 1.22.4, on Microsoft Windows [Version 10.0.19041.630], locale pl-PL)
Also very important for me as POS systems manufacturer.
OnScreen keyboard is not showing until any TextField input got focus. After that, keyboard will be shown on every keyboard input, also when no TextField widgets are on current Scaffold.
40 remaining items
nkek1027 commentedon Feb 6, 2025
I'm using flutter 3.22.3 and this issue no longer reproduces. Is anyone still having this issue? (Android 14, samsung one ui 6.1.1) (Did Samsung fix it...?)
keyboard type : Samsung Keyboard
20250206_173512_.mp4
DeuMiAn commentedon Mar 24, 2025
@nkek1027
I searched and analyzed your app and i think you used webview. I also don't have this symptom in textInput in webview, but when I use textInput provided by default by flutter, this symptom occurs.
mentz-nmi commentedon Apr 28, 2025
I still have this issue with flutter 3.29.3 and Gboard
we have this functionality that we can navigate through app with physical keyboard (with tab and shift tab)
if the page has any kind of TextField after leaving it and navigating to next element, app dismisses the keyboard and from the next one after that, again triggers the soft keyboard.
some logs that might be helpful:
Fix previous text input connection interrupts enter/space (#171973)
Fix previous text input connection interrupts enter/space (flutter#17…
github-actions commentedon Aug 11, 2025
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.Fix previous text input connection interrupts enter/space (flutter#17…
Fix previous text input connection interrupts enter/space (flutter#17…
Fix previous text input connection interrupts enter/space (flutter#17…
Fix previous text input connection interrupts enter/space (flutter#17…
Fix previous text input connection interrupts enter/space (#171973)