Skip to content

KeyboardListener is buggy after focusing a TextField #67915

Open

Description

@mikeesouth

This is primarily an issue for physical keyboards without touch screens but it is acting weird even with touch screens. I'm trying to support chromebooks with physical keyboard, that's why this issue is blocking me. I have not yet tested enough on slates with bluetooth keyboards but this may be a big problem with those devices too.

I posted this same question in a closed issue here but I didn't get any responses so I guess it's a new bug: #11177

Steps to Reproduce

I've created a simple repro: https://github.com/mikeesouth/chromebook_keyboard

This repro is as simple as this (but my repro is slightly improved to show focus and removing unused code):

  1. flutter create chromebook_keyboard
  2. Add final _keyboardListenerFocus = FocusNode(); to the state class
  3. Add String _keyName = 'N/A'; to the state class
  4. Override dispose() and call _keyboardListenerFocus.dispose(); in the state class
  5. Add the following to the build method (e.g. as children to the column class):
Text('Here is plain TextField:'),
Container(width: 200, child: TextField()),
SizedBox(height: 50),
Text(
    'Tap the green container to show the keycode using a RawKeyboardListener:'),
GestureDetector(
  onTap: () => _keyboardListenerFocus.requestFocus(),
  child: Container(
    width: 200,
    height: 100,
    color: Colors.green,
    alignment: Alignment.center,
    child: RawKeyboardListener(
      focusNode: _keyboardListenerFocus,
      onKey: (keyEvent) => setState(
          () => _keyName = keyEvent.data.logicalKey.debugName),
      child: Text('keyName = $_keyName'),
    ),
  ),
),

Expected results:
I expect the physical keyboard to work for the TextField and the physical keyboard to also work for the RawKeyboardListener when pressing the green container (to set focus to the keyboard listener). I expect the RawKeyboardListener to register keys (e.g. "A") when it's focused.

Actual results:
The actual result is that the RawKeyboardListener listens correctly if I focus it before focusing the TextField after application startup. But as soon as I focus the TextField and then switch back the focus to the RawKeyboardListener - then it does not register keys correctly.
If you start with the green container (keyboard listener) it recognizes all keys (i.e a, b, c, 1, 2, 3, space, left alt, left shift and so on). If you switch to the text field you can type text as expected. If you switch back to the green container - it no longer recognizes text, only modifiers such as left alt, left shift etc. BUT if you hold left alt, then it also recognizes letters and other keys (i.e. alt + a will display "_keyName = A"). Restart the app - the KeyboardListener works again but as soon as you focus the TextField the RawKeyboardListener will no longer recognize key presses.

Test device:
I'm trying this on a Chromebook without touch screen and it (of course) has a physical keyboard. The model is HP Chromebook 14-db0004no 14".

Additional information - buggy on touch screens:
Another interesting thing is that the keyboard listener correctly listens even after focusing the TextField. But an issue that may be related is that when I focus the TextField the soft keyboard shows as soon as I press a key on the physical keyboard - is this intended?

Steps to reproduce this issue that may be related:

  1. Start the app
  2. Tap the green container (to focus RawKeyboardListener)
  3. Press some keys (e.g. a, b, c) on my physical keyboard (Windows) - it registers correctly and no soft keyboard is displayed
  4. Tap the TextField (to focus it) - the soft keyboard pops up
  5. Type some text (e.g. "Hello World")
  6. Press back key on emulator to hide keyboard
  7. Tap the green container again (to focus RawKeyboardListener)
  8. Press some keys - the soft keyboard pops up again - why? (side note: on the Android Emulator this still registers the keypresses, on my Chromebook, this wouldn't recognize the keypresses if I don't hold down alt as described above)

I haven't started to test this on a hybrid device (i.e. touch screen + physical keyboard) but if the soft keyboard pops up focusing a text field when using a hybrid device with an attached keyboard, then it will become an issue for us. We would like to control when the soft keyboard shows up - it would be OK for it to show up automatically on a touch screen device without an attached keyboard.

Logs
[  +81 ms] executing: [C:\Stuff\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[  +47 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] f30b7f4db93ee747cd727df747941a28ead25ff5
[        ] executing: [C:\Stuff\flutter/] git tag --points-at HEAD
[  +35 ms] Exit code 0 from: git tag --points-at HEAD
[        ] 1.22.0-12.4.pre
           1.22.1
[   +5 ms] executing: [C:\Stuff\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[  +29 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] origin/stable
[        ] executing: [C:\Stuff\flutter/] git ls-remote --get-url origin
[  +25 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] https://github.com/flutter/flutter.git
[  +48 ms] executing: [C:\Stuff\flutter/] git rev-parse --abbrev-ref HEAD
[  +26 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] stable
[  +40 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +2 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[  +11 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe devices -l
[  +34 ms] List of devices attached
           192.168.90.216:22      device product:grunt model:grunt device:grunt_cheets transport_id:11
[   +5 ms] C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 shell getprop
[ +106 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[   +3 ms] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[   +1 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[ +143 ms] Generating C:\Stuff\git\chromebook_keyboard\android\app\src\main\java\io\flutter\plugins\GeneratedPluginRegistrant.java
[  +16 ms] ro.hardware = cheets
[        ] ro.build.characteristics = device
[  +29 ms] Starting incremental build...
[   +1 ms] Initializing file store
[   +6 ms] Skipping target: gen_localizations
[   +5 ms] complete
[   +4 ms] Launching lib\main.dart on grunt in debug mode...
[   +4 ms] C:\Stuff\flutter\bin\cache\dart-sdk\bin\dart.exe --disable-dart-dev C:\Stuff\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root
C:\Stuff\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk/ --incremental --target=flutter --debugger-module-names --experimental-emit-debug-metadata
-Ddart.developer.causal_async_stacks=true --output-dill C:\Users\micke\AppData\Local\Temp\flutter_tools.9fa4b6c3\flutter_tool.fecd069d\app.dill --packages .packages -Ddart.vm.profile=false
-Ddart.vm.product=false --bytecode-options=source-positions,local-var-info,debugger-stops,instance-field-initializers,keep-unreachable-code,avoid-closure-call-instructions --enable-asserts
--track-widget-creation --filesystem-scheme org-dartlang-root --initialize-from-dill build\cache.dill.track.dill
[   +9 ms] executing: C:\Stuff\AndroidSDK\build-tools\29.0.2\aapt dump xmltree C:\Stuff\git\chromebook_keyboard\build\app\outputs\flutter-apk\app.apk AndroidManifest.xml
[  +19 ms] Exit code 0 from: C:\Stuff\AndroidSDK\build-tools\29.0.2\aapt dump xmltree C:\Stuff\git\chromebook_keyboard\build\app\outputs\flutter-apk\app.apk AndroidManifest.xml
[        ] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1d
               A: android:compileSdkVersionCodename(0x01010573)="10" (Raw: "10")
               A: package="com.example.chromebook_keyboard" (Raw: "com.example.chromebook_keyboard")
               A: platformBuildVersionCode=(type 0x10)0x1d
               A: platformBuildVersionName=(type 0x10)0xa
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1d
               E: uses-permission (line=14)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: application (line=22)
                 A: android:label(0x01010001)="chromebook_keyboard" (Raw: "chromebook_keyboard")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:name(0x01010003)="io.flutter.app.FlutterApplication" (Raw: "io.flutter.app.FlutterApplication")
                 A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw: "androidx.core.app.CoreComponentFactory")
                 E: activity (line=28)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.example.chromebook_keyboard.MainActivity" (Raw: "com.example.chromebook_keyboard.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: meta-data (line=42)
                     A: android:name(0x01010003)="io.flutter.embedding.android.NormalTheme" (Raw: "io.flutter.embedding.android.NormalTheme")
                     A: android:resource(0x01010025)=@0x7f0a0001
                   E: meta-data (line=52)
                     A: android:name(0x01010003)="io.flutter.embedding.android.SplashScreenDrawable" (Raw: "io.flutter.embedding.android.SplashScreenDrawable")
                     A: android:resource(0x01010025)=@0x7f040000
                   E: intent-filter (line=56)
                     E: action (line=57)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=59)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
                 E: meta-data (line=66)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
[   +9 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 shell -x logcat -v time -t 1
[  +85 ms] Exit code 0 from: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 shell -x logcat -v time -t 1
[        ] --------- beginning of system
           10-12 14:05:05.714 E/TaskPersister(  133): File error accessing recents directory (directory doesn't exist?).
[   +1 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 shell -x logcat -v time -t 1
[ +151 ms] Exit code 0 from: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 shell -x logcat -v time -t 1
[   +1 ms] --------- beginning of system
           10-12 14:05:05.714 E/TaskPersister(  133): File error accessing recents directory (directory doesn't exist?).
[   +9 ms] <- compile package:chromebook_keyboard/main.dart
[  +16 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe version
[  +33 ms] Android Debug Bridge version 1.0.41
           Version 29.0.5-5949299
           Installed as C:\Stuff\AndroidSDK\platform-tools\adb.exe
[   +2 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe start-server
[  +25 ms] Building APK
[  +11 ms] Running Gradle task 'assembleDebug'...
[   +2 ms] gradle.properties already sets `android.enableR8`
[   +2 ms] Using gradle from C:\Stuff\git\chromebook_keyboard\android\gradlew.bat.
[   +1 ms] C:\Stuff\git\chromebook_keyboard\android\gradlew.bat mode: 33279 rwxrwxrwx.
[   +7 ms] executing: C:\Program Files\Android\Android Studio\jre\bin\java -version
[  +72 ms] Exit code 0 from: C:\Program Files\Android\Android Studio\jre\bin\java -version
[        ] openjdk version "1.8.0_212-release"
           OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
           OpenJDK 64-Bit Server VM (build 25.212-b04, mixed mode)
[   +2 ms] executing: [C:\Stuff\git\chromebook_keyboard\android/] C:\Stuff\git\chromebook_keyboard\android\gradlew.bat -Pverbose=true -Ptarget-platform=android-x86
-Ptarget=C:\Stuff\git\chromebook_keyboard\lib\main.dart -Ptrack-widget-creation=true -Pfilesystem-scheme=org-dartlang-root assembleDebug
[+2826 ms] > Task :app:compileFlutterBuildDebug
[   +1 ms] [  +76 ms] executing: [C:\Stuff\flutter/] git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] [  +42 ms] Exit code 0 from: git -c log.showSignature=false log -n 1 --pretty=format:%H
[        ] [        ] f30b7f4db93ee747cd727df747941a28ead25ff5
[        ] [        ] executing: [C:\Stuff\flutter/] git tag --points-at HEAD
[        ] [  +30 ms] Exit code 0 from: git tag --points-at HEAD
[        ] [        ] 1.22.0-12.4.pre
[        ]            1.22.1
[        ] [   +5 ms] executing: [C:\Stuff\flutter/] git rev-parse --abbrev-ref --symbolic @{u}
[        ] [  +22 ms] Exit code 0 from: git rev-parse --abbrev-ref --symbolic @{u}
[        ] [        ] origin/stable
[        ] [        ] executing: [C:\Stuff\flutter/] git ls-remote --get-url origin
[        ] [  +19 ms] Exit code 0 from: git ls-remote --get-url origin
[        ] [        ] https://github.com/flutter/flutter.git
[        ] [  +40 ms] executing: [C:\Stuff\flutter/] git rev-parse --abbrev-ref HEAD
[        ] [  +21 ms] Exit code 0 from: git rev-parse --abbrev-ref HEAD
[        ] [        ] stable
[        ] [  +23 ms] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] [   +1 ms] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] [   +7 ms] Artifact Instance of 'MaterialFonts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'GradleWrapper' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidMavenArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidGenSnapshotArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'AndroidInternalBuildArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterWebSdk' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterSdk' is not required, skipping update.
[        ] [        ] Artifact Instance of 'WindowsEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxEngineArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'LinuxFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'MacOSFuchsiaSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerSDKArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FlutterRunnerDebugSymbols' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'IosUsbArtifacts' is not required, skipping update.
[        ] [        ] Artifact Instance of 'FontSubsetArtifacts' is not required, skipping update.
[        ] [  +48 ms] Initializing file store
[        ] [   +9 ms] Done initializing file store
[        ] [  +25 ms] Skipping target: gen_localizations
[   +1 ms] [ +454 ms] kernel_snapshot: Starting due to {InvalidatedReason.inputChanged}
[   +1 ms] [  +16 ms] C:\Stuff\flutter\bin\cache\dart-sdk\bin\dart.exe --disable-dart-dev C:\Stuff\flutter\bin\cache\artifacts\engine\windows-x64\frontend_server.dart.snapshot --sdk-root
C:\Stuff\flutter\bin\cache\artifacts\engine\common\flutter_patched_sdk/ --target=flutter -Ddart.developer.causal_async_stacks=true -Ddart.vm.profile=false -Ddart.vm.product=false
--bytecode-options=source-positions,local-var-info,debugger-stops,instance-field-initializers,keep-unreachable-code,avoid-closure-call-instructions --enable-asserts --track-widget-creation
--no-link-platform --packages C:\Stuff\git\chromebook_keyboard\.packages --output-dill C:\Stuff\git\chromebook_keyboard\.dart_tool\flutter_build\d30679fb5b2608e85e4dafe663c5dae6\app.dill --depfile
C:\Stuff\git\chromebook_keyboard\.dart_tool\flutter_build\d30679fb5b2608e85e4dafe663c5dae6\kernel_snapshot.d package:chromebook_keyboard/main.dart
[+3857 ms] [+4560 ms] kernel_snapshot: Complete
[ +497 ms] [ +500 ms] debug_android_application: Starting due to {InvalidatedReason.inputChanged}
[ +108 ms] [  +91 ms] debug_android_application: Complete
[ +205 ms] [ +253 ms] Persisting file store
[   +1 ms] [   +5 ms] Done persisting file store
[        ] [   +4 ms] build succeeded.
[        ] [   +8 ms] "flutter assemble" took 5 995ms.
[        ] [   +2 ms] ensureAnalyticsSent: 0ms
[        ] [        ] Running shutdown hooks
[        ] [        ] Shutdown hooks complete
[        ] [        ] exiting with code 0
[ +184 ms] > Task :app:packLibsflutterBuildDebug UP-TO-DATE
[   +1 ms] > Task :app:preBuild UP-TO-DATE
[        ] > Task :app:preDebugBuild UP-TO-DATE
[        ] > Task :app:compileDebugAidl NO-SOURCE
[        ] > Task :app:checkDebugManifest UP-TO-DATE
[        ] > Task :app:compileDebugRenderscript NO-SOURCE
[        ] > Task :app:generateDebugBuildConfig UP-TO-DATE
[        ] > Task :app:cleanMergeDebugAssets
[        ] > Task :app:mergeDebugShaders UP-TO-DATE
[        ] > Task :app:compileDebugShaders UP-TO-DATE
[        ] > Task :app:generateDebugAssets UP-TO-DATE
[        ] > Task :app:mergeDebugAssets
[ +194 ms] > Task :app:copyFlutterAssetsDebug
[        ] > Task :app:mainApkListPersistenceDebug UP-TO-DATE
[        ] > Task :app:generateDebugResValues UP-TO-DATE
[        ] > Task :app:generateDebugResources UP-TO-DATE
[        ] > Task :app:mergeDebugResources UP-TO-DATE
[        ] > Task :app:createDebugCompatibleScreenManifests UP-TO-DATE
[        ] > Task :app:processDebugManifest UP-TO-DATE
[        ] > Task :app:processDebugResources UP-TO-DATE
[        ] > Task :app:compileDebugKotlin UP-TO-DATE
[        ] > Task :app:javaPreCompileDebug UP-TO-DATE
[        ] > Task :app:compileDebugJavaWithJavac UP-TO-DATE
[        ] > Task :app:compileDebugSources UP-TO-DATE
[        ] > Task :app:processDebugJavaRes NO-SOURCE
[        ] > Task :app:mergeDebugJavaResource UP-TO-DATE
[        ] > Task :app:checkDebugDuplicateClasses UP-TO-DATE
[        ] > Task :app:transformClassesWithDexBuilderForDebug UP-TO-DATE
[        ] > Task :app:desugarDebugFileDependencies UP-TO-DATE
[        ] > Task :app:mergeExtDexDebug UP-TO-DATE
[        ] > Task :app:mergeDexDebug UP-TO-DATE
[        ] > Task :app:validateSigningDebug UP-TO-DATE
[        ] > Task :app:signingConfigWriterDebug UP-TO-DATE
[        ] > Task :app:mergeDebugJniLibFolders UP-TO-DATE
[        ] > Task :app:mergeDebugNativeLibs UP-TO-DATE
[  +98 ms] > Task :app:stripDebugDebugSymbols UP-TO-DATE
[        ] Compatible side by side NDK version was not found.
[ +691 ms] > Task :app:packageDebug
[  +95 ms] > Task :app:assembleDebug
[        ] BUILD SUCCESSFUL in 8s
[        ] 31 actionable tasks: 6 executed, 25 up-to-date
[ +517 ms] Running Gradle task 'assembleDebug'... (completed in 9,4s)
[  +19 ms] calculateSha: LocalDirectory: 'C:\Stuff\git\chromebook_keyboard\build\app\outputs\flutter-apk'/app.apk
[  +10 ms] calculateSha: reading file took 9us
[ +343 ms] calculateSha: computing sha took 342us
[   +4 ms] √ Built build\app\outputs\flutter-apk\app-debug.apk.
[   +2 ms] executing: C:\Stuff\AndroidSDK\build-tools\29.0.2\aapt dump xmltree C:\Stuff\git\chromebook_keyboard\build\app\outputs\flutter-apk\app.apk AndroidManifest.xml
[  +21 ms] Exit code 0 from: C:\Stuff\AndroidSDK\build-tools\29.0.2\aapt dump xmltree C:\Stuff\git\chromebook_keyboard\build\app\outputs\flutter-apk\app.apk AndroidManifest.xml
[        ] N: android=http://schemas.android.com/apk/res/android
             E: manifest (line=2)
               A: android:versionCode(0x0101021b)=(type 0x10)0x1
               A: android:versionName(0x0101021c)="1.0.0" (Raw: "1.0.0")
               A: android:compileSdkVersion(0x01010572)=(type 0x10)0x1d
               A: android:compileSdkVersionCodename(0x01010573)="10" (Raw: "10")
               A: package="com.example.chromebook_keyboard" (Raw: "com.example.chromebook_keyboard")
               A: platformBuildVersionCode=(type 0x10)0x1d
               A: platformBuildVersionName=(type 0x10)0xa
               E: uses-sdk (line=7)
                 A: android:minSdkVersion(0x0101020c)=(type 0x10)0x10
                 A: android:targetSdkVersion(0x01010270)=(type 0x10)0x1d
               E: uses-permission (line=14)
                 A: android:name(0x01010003)="android.permission.INTERNET" (Raw: "android.permission.INTERNET")
               E: application (line=22)
                 A: android:label(0x01010001)="chromebook_keyboard" (Raw: "chromebook_keyboard")
                 A: android:icon(0x01010002)=@0x7f080000
                 A: android:name(0x01010003)="io.flutter.app.FlutterApplication" (Raw: "io.flutter.app.FlutterApplication")
                 A: android:debuggable(0x0101000f)=(type 0x12)0xffffffff
                 A: android:appComponentFactory(0x0101057a)="androidx.core.app.CoreComponentFactory" (Raw: "androidx.core.app.CoreComponentFactory")
                 E: activity (line=28)
                   A: android:theme(0x01010000)=@0x7f0a0000
                   A: android:name(0x01010003)="com.example.chromebook_keyboard.MainActivity" (Raw: "com.example.chromebook_keyboard.MainActivity")
                   A: android:launchMode(0x0101001d)=(type 0x10)0x1
                   A: android:configChanges(0x0101001f)=(type 0x11)0x40003fb4
                   A: android:windowSoftInputMode(0x0101022b)=(type 0x11)0x10
                   A: android:hardwareAccelerated(0x010102d3)=(type 0x12)0xffffffff
                   E: meta-data (line=42)
                     A: android:name(0x01010003)="io.flutter.embedding.android.NormalTheme" (Raw: "io.flutter.embedding.android.NormalTheme")
                     A: android:resource(0x01010025)=@0x7f0a0001
                   E: meta-data (line=52)
                     A: android:name(0x01010003)="io.flutter.embedding.android.SplashScreenDrawable" (Raw: "io.flutter.embedding.android.SplashScreenDrawable")
                     A: android:resource(0x01010025)=@0x7f040000
                   E: intent-filter (line=56)
                     E: action (line=57)
                       A: android:name(0x01010003)="android.intent.action.MAIN" (Raw: "android.intent.action.MAIN")
                     E: category (line=59)
                       A: android:name(0x01010003)="android.intent.category.LAUNCHER" (Raw: "android.intent.category.LAUNCHER")
                 E: meta-data (line=66)
                   A: android:name(0x01010003)="flutterEmbedding" (Raw: "flutterEmbedding")
                   A: android:value(0x01010024)=(type 0x10)0x2
[   +6 ms] Stopping app 'app.apk' on grunt.
[        ] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 shell am force-stop com.example.chromebook_keyboard
[ +123 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 shell pm list packages com.example.chromebook_keyboard
[ +103 ms] package:com.example.chromebook_keyboard
[   +1 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 shell cat /data/local/tmp/sky.com.example.chromebook_keyboard.sha1
[  +86 ms] 1e9971d7f02b1155f5a9c5f4504744c688f0f1e1
[   +1 ms] Installing APK.
[   +1 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe version
[  +22 ms] Android Debug Bridge version 1.0.41
           Version 29.0.5-5949299
           Installed as C:\Stuff\AndroidSDK\platform-tools\adb.exe
[   +1 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe start-server
[  +22 ms] Installing build\app\outputs\flutter-apk\app.apk...
[   +1 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 install -t -r C:\Stuff\git\chromebook_keyboard\build\app\outputs\flutter-apk\app.apk
[+16255 ms] Performing Streamed Install
                     Success
[   +1 ms] Installing build\app\outputs\flutter-apk\app.apk... (completed in 16,3s)
[        ] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 shell echo -n f6d601e63c9fbcfe3dcea9e690eb81c5d3954a21 > /data/local/tmp/sky.com.example.chromebook_keyboard.sha1 [ +124 ms] grunt startApp
[   +2 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 shell am start -a android.intent.action.RUN -f 0x20000000 --ez enable-background-compilation true --ez
enable-dart-profiling true --ez enable-checked-mode true --ez verify-entry-points true com.example.chromebook_keyboard/com.example.chromebook_keyboard.MainActivity
[ +213 ms] Starting: Intent { act=android.intent.action.RUN flg=0x20000000 cmp=com.example.chromebook_keyboard/.MainActivity (has extras) }
[        ] Waiting for observatory port to be available...
[+2419 ms] Observatory URL on device: http://127.0.0.1:46247/NufBGxrGSNc=/
[   +1 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 forward tcp:0 tcp:46247
[  +22 ms] 52402
[        ] Forwarded host port 52402 to device port 46247 for Observatory
[   +3 ms] Caching compiled dill
[  +16 ms] Connecting to service protocol: http://127.0.0.1:52402/NufBGxrGSNc=/
[   +1 ms] DDS is currently disabled due to https://github.com/flutter/flutter/issues/62507
[ +475 ms] Successfully connected to service protocol: http://127.0.0.1:52402/NufBGxrGSNc=/
[   +1 ms] Waiting for grunt to report its views...
[ +116 ms] Waiting for grunt to report its views... (completed in 115ms)
[ +147 ms] DevFS: Creating new filesystem on the device (null)
[ +125 ms] DevFS: Created new filesystem on the device (file:///data/user/0/com.example.chromebook_keyboard/code_cache/chromebook_keyboardCHPXFD/chromebook_keyboard/)
[   +2 ms] Updating assets
[  +57 ms] Syncing files to device grunt...
[   +2 ms] Scanning asset files
[   +1 ms] <- reset
[        ] Compiling dart to kernel with 0 updated files
[   +1 ms] <- recompile package:chromebook_keyboard/main.dart cd00f21c-5a47-47ef-adbf-5dab26f5ae23
[        ] <- cd00f21c-5a47-47ef-adbf-5dab26f5ae23
[  +41 ms] Updating files
[ +502 ms] DevFS: Sync finished
[   +1 ms] Syncing files to device grunt... (completed in 550ms)
[        ] Synced 1.8MB.
[        ] <- accept
[ +136 ms] Connected to _flutterView/0xdb4f7010.
[   +1 ms] Flutter run key commands.
[   +1 ms] r Hot reload.
[        ] R Hot restart.
[        ] h Repeat this help message.
[   +1 ms] d Detach (terminate "flutter run" but leave application running).
[        ] c Clear the screen
[        ] q Quit (terminate the application on the device).
[        ] An Observatory debugger and profiler on grunt is available at: http://127.0.0.1:52402/NufBGxrGSNc=/
[+17348 ms] Application finished.
[   +2 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 forward --list
[  +24 ms] Exit code 0 from: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 forward --list
[        ] 192.168.90.216:22 tcp:52402 tcp:46247
[   +1 ms] executing: C:\Stuff\AndroidSDK\platform-tools\adb.exe -s 192.168.90.216:22 forward --remove tcp:52402

Analyzing chromebook_keyboard...
No issues found! (ran in 1.2s)

[√] Flutter (Channel stable, 1.22.1, on Microsoft Windows [Version 10.0.19042.546], locale sv-SE)
• Flutter version 1.22.1 at C:\Stuff\flutter
• Framework revision f30b7f4 (4 days ago), 2020-10-08 10:06:30 -0700
• Engine revision 75bef9f
• Dart version 2.10.1

[√] Android toolchain - develop for Android devices (Android SDK version 29.0.2)
• Android SDK at C:\Stuff\AndroidSDK
• Platform android-29, build-tools 29.0.2
• ANDROID_HOME = C:\Stuff\AndroidSDK
• Java binary at: C:\Program Files\Android\Android Studio\jre\bin\java
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)
• All Android licenses accepted.

[√] Android Studio (version 3.6)
• Android Studio at C:\Program Files\Android\Android Studio
• Flutter plugin version 42.1.1
• Dart plugin version 191.8593
• Java version OpenJDK Runtime Environment (build 1.8.0_212-release-1586-b04)

[√] VS Code (version 1.50.0)
• VS Code at C:\Users\micke\AppData\Local\Programs\Microsoft VS Code
• Flutter extension version 3.15.0

[√] Connected device (1 available)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 10 (API 29) (emulator)
! Device 192.168.90.216:22 is offline.

Activity

  1. mikeesouth commented on Oct 12, 2020

    @mikeesouth
    Author

    I just tested with Flutter 1.23.0-8.0.pre.286 • channel master - same behavior both on my chromebook and the android emulator.

  2. TahaTesser commented on Oct 12, 2020

    @TahaTesser
    Contributor

    Reproduced on emulator

    code sample
    import 'package:flutter/material.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter - flutter/issues/#67915',
          theme: ThemeData(
            primarySwatch: Colors.blue,
            visualDensity: VisualDensity.adaptivePlatformDensity,
          ),
          home: MyHomePage(title: 'Flutter - flutter/issues/#67915'),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      MyHomePage({Key key, this.title}) : super(key: key);
      final String title;
    
      @override
      _MyHomePageState createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      final _keyboardListenerFocus = FocusNode();
      String _keyName = 'N/A';
      bool _listenerActive = false;
    
      @override
      void initState() {
        super.initState();
    
        _keyboardListenerFocus.addListener(() {
          setState(() => _listenerActive = _keyboardListenerFocus.hasFocus);
        });
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: Text(widget.title)),
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                Text('Plain TextField:'),
                Container(width: 200, child: TextField()),
                SizedBox(height: 50),
                Text('Tap the green container to focus the RawKeyboardListener:'),
                SizedBox(height: 5),
                GestureDetector(
                  onTap: () => _keyboardListenerFocus.requestFocus(),
                  child: Container(
                    width: 200,
                    height: 100,
                    color: _listenerActive ? Colors.lightGreen : Colors.green,
                    alignment: Alignment.center,
                    child: RawKeyboardListener(
                      focusNode: _keyboardListenerFocus,
                      onKey: (keyEvent) => setState(
                          () => _keyName = keyEvent.data.logicalKey.debugName),
                      child: _listenerActive
                          ? Text(
                              'Listener focused!\nPress some keys.\nkeyName = $_keyName',
                              textAlign: TextAlign.center,
                            )
                          : Text(
                              'Listener not focused\nTap here to focus\n',
                              textAlign: TextAlign.center,
                            ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        );
      }
    
      @override
      void dispose() {
        _keyboardListenerFocus.dispose();
    
        super.dispose();
      }
    }
    flutter doctor -v
    [✓] Flutter (Channel stable, 1.22.1, on Mac OS X 10.15.7 19H2, locale en-GB)
        • Flutter version 1.22.1 at /Users/tahatesser/Code/flutter_stable
        • Framework revision f30b7f4db9 (4 days ago), 2020-10-08 10:06:30 -0700
        • Engine revision 75bef9f6c8
        • Dart version 2.10.1
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2)
        • Android SDK at /Users/tahatesser/Code/sdk
        • Platform android-30, build-tools 30.0.2
        • ANDROID_HOME = /Users/tahatesser/Code/sdk
        • Java binary at: /Applications/Android
          Studio.app/Contents/jre/jdk/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build
          1.8.0_242-release-1644-b3-6222593)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 12.0.1)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Xcode 12.0.1, Build version 12A7300
        • CocoaPods version 1.10.0.rc.1
    
    [✓] Android Studio (version 4.0)
        • Android Studio at /Applications/Android Studio.app/Contents
        • Flutter plugin version 50.0.1
        • Dart plugin version 193.7547
        • Java version OpenJDK Runtime Environment (build
          1.8.0_242-release-1644-b3-6222593)
    
    [✓] VS Code (version 1.50.0)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.15.0
    
     
    [!] Connected device                          
        ! No devices available
    
    ! Doctor found issues in 1 category.
  3. added
    a: text inputEntering text in a text field or keyboard related problems
    engineflutter/engine related. See also e: labels.
    p: material_uimaterial_ui package in flutter/packages
    frameworkflutter/packages/flutter repository. See also f: labels.
    has reproducible stepsThe issue has been confirmed reproducible and is ready to work on
    on Oct 12, 2020
  4. amitozalvo commented on Oct 21, 2020

    @amitozalvo

    Also experiencing this problem, tried to debug it but it seems that the keydown / up events don't fire at all when it comes to letters.
    Can't find them on top of the stack frame when debugging

  5. mikeesouth commented on Oct 27, 2020

    @mikeesouth
    Author

    Is there any way to "vote" for this issue, get an estimated fix date or help out to speed up a fix? This is a real blocker for all chromebooks (at least all with a physical keyboard). Chromebook is becoming one of our primary platforms and Chromebooks are growing rapidly in popularity for our target audiences (education).

  6. GintautasMickus commented on Oct 27, 2020

    @GintautasMickus

    I am also having the same problem on the Android TV platform... After focusing the text field the remote control buttons are useless....

  7. amitozalvo commented on Oct 27, 2020

    @amitozalvo

    Fot me it happens on android, ios and web.
    I'm using an external bluetooth barcode scanner and it's very frustrating for my users

  8. amitozalvo commented on Oct 29, 2020

    @amitozalvo

    I am able to "fix" this behavior without restarting the app by initiating a barcode scan with the camera of the phone (using the library barcode-scan).

    It's really not a workaround but this is what my users are doing right now to work with it

  9. 29 remaining items

  10. dam-ease commented on Feb 28, 2024

    @dam-ease

    I can reproduce this on the latest master and stable channels.

    Screen Record

    untitled.webm

    Code Sample

    import 'package:flutter/material.dart';
    
    void main() {
      runApp(MyApp());
    }
    
    class MyApp extends StatelessWidget {
      // This widget is the root of your application.
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          title: 'Flutter - flutter/issues/#67915',
          theme: ThemeData(
            primarySwatch: Colors.blue,
            visualDensity: VisualDensity.adaptivePlatformDensity,
          ),
          home: MyHomePage(title: 'Flutter - flutter/issues/#67915'),
        );
      }
    }
    
    class MyHomePage extends StatefulWidget {
      MyHomePage({Key? key, required this.title}) : super(key: key);
      final String title;
    
      @override
      _MyHomePageState createState() => _MyHomePageState();
    }
    
    class _MyHomePageState extends State<MyHomePage> {
      final _keyboardListenerFocus = FocusNode();
      String _keyName = 'N/A';
      bool _listenerActive = false;
    
      @override
      void initState() {
        super.initState();
    
        _keyboardListenerFocus.addListener(() {
          setState(() => _listenerActive = _keyboardListenerFocus.hasFocus);
        });
      }
    
      @override
      Widget build(BuildContext context) {
        return Scaffold(
          appBar: AppBar(title: Text(widget.title)),
          body: Center(
            child: Column(
              mainAxisAlignment: MainAxisAlignment.center,
              children: <Widget>[
                const Text('Plain TextField:'),
                Container(width: 200, child: const TextField()),
                const SizedBox(height: 50),
                const Text('Tap the green container to focus the RawKeyboardListener:'),
                const SizedBox(height: 5),
                GestureDetector(
                  onTap: () => _keyboardListenerFocus.requestFocus(),
                  child: Container(
                    width: 200,
                    height: 100,
                    color: _listenerActive ? Colors.lightGreen : Colors.green,
                    alignment: Alignment.center,
                    child: KeyboardListener(
                      focusNode: _keyboardListenerFocus,
                      onKeyEvent: (keyEvent) =>
                          setState(() => _keyName = keyEvent.logicalKey.debugName!),
                      child: _listenerActive
                          ? Text(
                              'Listener focused!\nPress some keys.\nkeyName = $_keyName',
                              textAlign: TextAlign.center,
                            )
                          : const Text(
                              'Listener not focused\nTap here to focus\n',
                              textAlign: TextAlign.center,
                            ),
                    ),
                  ),
                ),
              ],
            ),
          ),
        );
      }
    
      @override
      void dispose() {
        _keyboardListenerFocus.dispose();
    
        super.dispose();
      }
    }
    

    stable, master flutter doctor -v

    [!] Flutter (Channel stable, 3.19.1, on macOS 14.2.1 23C71 darwin-arm64, locale
        en-NG)
        • Flutter version 3.19.1 on channel stable at
          /Users/damilolaalimi/sdks/flutter
        ! Warning: `dart` on your path resolves to
          /opt/homebrew/Cellar/dart/3.1.5/libexec/bin/dart, which is not inside your
          current Flutter SDK checkout at /Users/damilolaalimi/sdks/flutter.
          Consider adding /Users/damilolaalimi/sdks/flutter/bin to the front of your
          path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision abb292a07e (8 days ago), 2024-02-20 14:35:05 -0800
        • Engine revision 04817c99c9
        • Dart version 3.3.0
        • DevTools version 2.31.1
        • If those were intentional, you can disregard the above warnings; however
          it is recommended to use "git" directly to perform update checks and
          upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/damilolaalimi/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • ANDROID_HOME = /Users/damilolaalimi/Library/Android/sdk
        • Java binary at: /Applications/Android
          Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build
          17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.2)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 15C500b
        • CocoaPods version 1.14.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • 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
          17.0.6+0-17.0.6b802.4-9586694)
    
    [!] Android Studio (version unknown)
        • Android Studio at /Users/damilolaalimi/Downloads/Android Studio
          Preview.app/Contents
        • 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
        ✗ Unable to determine Android Studio version.
        • Java version OpenJDK Runtime Environment (build
          17.0.7+0-17.0.7b1000.6-10550314)
    
    [✓] VS Code (version 1.86.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.78.0
    
    [✓] VS Code (version 1.83.1)
        • VS Code at /Users/damilolaalimi/Downloads/Visual Studio Code.app/Contents
        • Flutter extension version 3.78.0
    
    [✓] Connected device (4 available)
        • sdk gphone64 arm64 (mobile) • emulator-5554             • android-arm64  •
          Android 14 (API 34) (emulator)
        • Damilola’s iPhone (mobile)  • 00008110-001964480AE1801E • ios            •
          iOS 17.1.1 21B91
        • macOS (desktop)             • macos                     • darwin-arm64   •
          macOS 14.2.1 23C71 darwin-arm64
        • Chrome (web)                • chrome                    • web-javascript •
          Google Chrome 122.0.6261.69
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 2 categories.
    
    [!] Flutter (Channel master, 3.20.0-15.0.pre.26, on macOS 14.2.1 23C71 darwin-arm64, locale en-NG)
        • Flutter version 3.20.0-15.0.pre.26 on channel master at /Users/damilolaalimi/fvm/versions/master
        ! Warning: `dart` on your path resolves to /opt/homebrew/Cellar/dart/3.1.5/libexec/bin/dart, which is not inside your current Flutter SDK checkout at /Users/damilolaalimi/fvm/versions/master. Consider adding /Users/damilolaalimi/fvm/versions/master/bin to the front of your path.
        • Upstream repository https://github.com/flutter/flutter.git
        • Framework revision 82ffde7ddf (3 hours ago), 2024-02-28 07:39:21 +0000
        • Engine revision 8acc96d405
        • Dart version 3.4.0 (build 3.4.0-185.0.dev)
        • DevTools version 2.33.0-dev.11
        • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades.
    
    [✓] Android toolchain - develop for Android devices (Android SDK version 34.0.0)
        • Android SDK at /Users/damilolaalimi/Library/Android/sdk
        • Platform android-34, build-tools 34.0.0
        • ANDROID_HOME = /Users/damilolaalimi/Library/Android/sdk
        • Java binary at: /Applications/Android Studio.app/Contents/jbr/Contents/Home/bin/java
        • Java version OpenJDK Runtime Environment (build 17.0.6+0-17.0.6b802.4-9586694)
        • All Android licenses accepted.
    
    [✓] Xcode - develop for iOS and macOS (Xcode 15.2)
        • Xcode at /Applications/Xcode.app/Contents/Developer
        • Build 15C500b
        • CocoaPods version 1.14.3
    
    [✓] Chrome - develop for the web
        • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
    
    [✓] Android Studio (version 2022.2)
        • Android Studio at /Applications/Android Studio.app/Contents
        • 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 17.0.6+0-17.0.6b802.4-9586694)
    
    [!] Android Studio (version unknown)
        • Android Studio at /Users/damilolaalimi/Downloads/Android Studio Preview.app/Contents
        • 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
        ✗ Unable to determine Android Studio version.
        • Java version OpenJDK Runtime Environment (build 17.0.7+0-17.0.7b1000.6-10550314)
    
    [✓] VS Code (version 1.86.1)
        • VS Code at /Applications/Visual Studio Code.app/Contents
        • Flutter extension version 3.78.0
    
    [✓] VS Code (version 1.83.1)
        • VS Code at /Users/damilolaalimi/Downloads/Visual Studio Code.app/Contents
        • Flutter extension version 3.78.0
    
    [✓] Connected device (5 available)
        • sdk gphone64 arm64 (mobile)     • emulator-5554             • android-arm64  • Android 14 (API 34) (emulator)
        • Damilola’s iPhone (mobile)      • 00008110-001964480AE1801E • ios            • iOS 17.1.1 21B91
        • macOS (desktop)                 • macos                     • darwin-arm64   • macOS 14.2.1 23C71 darwin-arm64
        • Mac Designed for iPad (desktop) • mac-designed-for-ipad     • darwin         • macOS 14.2.1 23C71 darwin-arm64
        • Chrome (web)                    • chrome                    • web-javascript • Google Chrome 122.0.6261.69
    
    [✓] Network resources
        • All expected network resources are available.
    
    ! Doctor found issues in 2 categories.
    

  11. changed the title [-]RawKeyboardListener is buggy after focusing a TextField[/-] [+]KeyboardListener is buggy after focusing a TextField[/+] on Feb 28, 2024
  12. Lenny4 commented on Mar 29, 2024

    @Lenny4

    Hello I found a workaround to this issue which I explain on stackoverflow here: https://stackoverflow.com/questions/78245462/keyboardlistener-is-buggy-after-focusing-a-textfield/78245463

    I paste the example below, for full explanation go on stackoverflow:

    import 'dart:io';
    
    import 'package:flutter/material.dart';
    import 'package:flutter/services.dart';
    import 'package:flutter_barcode_listener/flutter_barcode_listener.dart';
    import 'package:flutter_hooks/flutter_hooks.dart';
    
    void main() => runApp(const MyApp());
    
    class MyApp extends StatelessWidget {
      const MyApp({super.key});
    
      @override
      Widget build(BuildContext context) {
        return MaterialApp(
          theme: ThemeData(useMaterial3: true),
          home: const Root(),
        );
      }
    }
    
    class ScanReader extends HookWidget {
      final void Function(String value) onScan;
    
      const ScanReader({super.key, required this.onScan});
    
      @override
      Widget build(BuildContext context) {
        var controller = useState<TextEditingController>(TextEditingController());
        var keyboardShowed = useState<bool>(false);
    
        openKeyboard() {
          keyboardShowed.value = true;
          SystemChannels.textInput.invokeMethod("TextInput.show");
        }
    
        closeKeyboard() {
          keyboardShowed.value = false;
          SystemChannels.textInput.invokeMethod("TextInput.hide");
          controller.value.clear();
        }
    
        useEffect(() {
          thisHandle(KeyEvent keyEvent) {
            if (keyboardShowed.value == false) {
              return false;
            }
            if (keyEvent.logicalKey == LogicalKeyboardKey.backspace &&
                controller.value.text.isNotEmpty) {
              controller.value.text = controller.value.text
                  .substring(0, controller.value.text.length - 1);
            } else if (keyEvent.logicalKey == LogicalKeyboardKey.enter) {
              onScan(controller.value.text);
              closeKeyboard();
            } else {
              var newChar = keyEvent.character.toString();
              if (newChar.length == 1) {
                controller.value.text += newChar;
              }
            }
            return true;
          }
    
          HardwareKeyboard.instance.addHandler(thisHandle);
          return () {
            HardwareKeyboard.instance.removeHandler(thisHandle);
          };
        }, []);
    
        return Column(
          children: <Widget>[
            BarcodeKeyboardListener(
              bufferDuration: const Duration(milliseconds: 200),
              onBarcodeScanned: (newBarcode) {
                if (newBarcode != '') {
                  onScan(newBarcode);
                }
              },
              useKeyDownEvent: Platform.isWindows,
              child: TextField(
                autofocus: false,
                readOnly: true,
                keyboardType: TextInputType.text,
                controller: controller.value,
                decoration: InputDecoration(
                  suffixIcon: IconButton(
                    icon: const Icon(Icons.close),
                    onPressed: () {
                      closeKeyboard();
                    },
                  ),
                  hintText: 'Search...',
                ),
                onTap: () {
                  openKeyboard();
                },
              ),
            ),
          ],
        );
      }
    }
    
    class Root extends HookWidget {
      const Root({Key? key}) : super(key: key);
    
      @override
      Widget build(BuildContext context) {
    
        return SafeArea(
          child: Scaffold(
            body: ScanReader(onScan: (String value) {
              print('$value');
            }),
          ),
        );
      }
    }
  13. mikeesouth commented on Mar 10, 2025

    @mikeesouth
    Author

    More than four years and this still isn't fixed 😢

    While I appreciate the fix from @Lenny4 a year ago, it's far from an ideal fix. Setting readonly on a textfield stops us from selecting text, moving the cursor and other stuff (yes - this can probably be fixed with more special solutions but in practice it's a struggle that adds a lot of complexity).

    I tried this example again with Flutter 3.29.1 on a brand new Android slate with Android 15 - the problem persists. The problem also persist on my old Chromebook.

    This problem does not occur on iPad with physical keyboards, it seems to be an Android only problem.

    @TahaTesser, @gnprice, @dam-ease do you have any tips on how I can raise the priority of this issue? Sorry for pinging you but you all added labels to the issue so I'm hoping that you have insights in how this can be prioritized.

  14. added
    packageflutter/packages repository. See also p: labels.
    and removed
    frameworkflutter/packages/flutter repository. See also f: labels.
    on Aug 17, 2026
  15. added
    team-designOwned by Design Languages team
    triaged-designTriaged by Design Languages team
    and removed on Aug 26, 2026
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

    P2Important issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.found in release: 3.19Found to occur in 3.19found in release: 3.20Found to occur in 3.20has reproducible stepsThe issue has been confirmed reproducible and is ready to work onp: material_uimaterial_ui package in flutter/packagespackageflutter/packages repository. See also p: labels.platform-chromebookChromebook applications specificallyteam-designOwned by Design Languages teamtriaged-designTriaged by Design Languages team

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions