Skip to content

Flutter OnScreen Keyboard opens on physical key press #51478

Closed
flutter-team-archive/engine
#49829

Description

@SebastianRuettger

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

  1. Screen with one or more Textfields
  2. focus one or more
  3. navigate to new screen
  4. 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

  1. added
    a: text inputEntering text in a text field or keyboard related problems
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Feb 26, 2020
  2. artemtkachenko commented on Apr 14, 2020

    @artemtkachenko

    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.

  3. darshankawar commented on Aug 25, 2020

    @darshankawar
    Member

    Hi @SebastianRuettger,
    Can you please confirm if you still experience the issue on latest Stable version ?
    Thanks.

  4. added
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 25, 2020
  5. SebastianRuettger commented on Aug 25, 2020

    @SebastianRuettger
    Author
  6. removed
    waiting for responseThe Flutter team cannot make further progress on this issue until the original reporter responds
    on Aug 25, 2020
  7. Guillaume-Fortin commented on Sep 4, 2020

    @Guillaume-Fortin

    i have same problem with flutter 1.17.5.
    i will test on 1.20.3

  8. Guillaume-Fortin commented on Sep 7, 2020

    @Guillaume-Fortin

    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

  9. Guillaume-Fortin commented on Sep 7, 2020

    @Guillaume-Fortin

    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.

  10. CyrilHu commented on Oct 14, 2020

    @CyrilHu

    i have same problem with flutter 1.22.1

  11. nrutledge commented on Nov 20, 2020

    @nrutledge

    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.

  12. pkotowski commented on Dec 10, 2020

    @pkotowski

    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.

  13. 40 remaining items

  14. nkek1027 commented on Feb 6, 2025

    @nkek1027

    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
  15. DeuMiAn commented on Mar 24, 2025

    @DeuMiAn

    @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.

  16. mentz-nmi commented on Apr 28, 2025

    @mentz-nmi

    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:

    I/HandWritingStubImpl(29379): getCurrentKeyboardType: 1
    
    I/HandWritingStubImpl(29379): isKeyboardTypeChanged: false
    
    D/InputMethodManager(29379): showSoftInput() view=io.flutter.embedding.android.FlutterView{f477820 VFED..... .F...... 0,0-1080,2270 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
    
    2
    
    I/HandWritingStubImpl(29379): isKeyboardTypeChanged: false
    
    D/InputMethodManager(29379): showSoftInput() view=io.flutter.embedding.android.FlutterView{f477820 VFED..... .F...... 0,0-1080,2270 #1 aid=1073741824} flags=0 reason=SHOW_SOFT_INPUT
    
    I/AssistStructure(29379): Flattened final assist data: 496 bytes, containing 1 windows, 3 views
    
    I/HandWritingStubImpl(29379): isKeyboardTypeChanged: false
    
    W/OnBackInvokedCallback(29379): OnBackInvokedCallback is not enabled for the application.
    
    W/OnBackInvokedCallback(29379): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
    
    2
    
    D/InsetsController(29379): show(ime(), fromIme=true)
    
    3
    
    I/HandWritingStubImpl(29379): isKeyboardTypeChanged: false
    
    W/OnBackInvokedCallback(29379): OnBackInvokedCallback is not enabled for the application.
    
    W/OnBackInvokedCallback(29379): Set 'android:enableOnBackInvokedCallback="true"' in the application manifest.
    
    I/HandWritingStubImpl(29379): isKeyboardTypeChanged: false
    
    D/InsetsController(29379): show(ime(), fromIme=true)
    
    I/HandWritingStubImpl(29379): isKeyboardTypeChanged: false
    
  17. added
    r: fixedIssue is closed as already fixed in a newer version
    on Jul 28, 2025
  18. github-actions commented on Aug 11, 2025

    @github-actions

    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 -v and a minimal reproduction of the issue.

  19. locked as resolved and limited conversation to collaborators on Aug 11, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    P3Issues that are less important to the Flutter projecta: text inputEntering text in a text field or keyboard related problemse: device-specificOnly manifests on certain devicesframeworkflutter/packages/flutter repository. See also f: labels.r: fixedIssue is closed as already fixed in a newer versionteam-text-inputOwned by Text Input teamtriaged-text-inputTriaged by Text Input team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions