You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
TextField issue: TextField doesn't get focus in Android #26563
I've just upgraded Flutter to v1.1.10-pre.58 and TextField doensn't get focus in Android anymore. (tap in TextField but keyboard doesn't open up)
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, v1.1.10-pre.58, on Microsoft Windows [Version 10.0.17134.523], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Android Studio (version 3.2)
[!] IntelliJ IDEA Community Edition (version 2018.3)
X Flutter plugin not installed; this adds Flutter specific functionality.
X Dart plugin not installed; this adds Dart specific functionality.
[!] Connected device
! No devices available
! Doctor found issues in 2 categories.
To investigate we would need a minimal runnable reproduction
as a single file so that we can just copy your code into lib/main.dart of a new project and run to reproduce.
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel master, v1.1.10-pre.73, on Mac OS X 10.14 18A391, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.1)
[✓] VS Code (version 1.30.2)
[✓] Connected device (1 available)
• No issues found!
I'm running Android 9, kernel version 4.4.116-g921edebf2ac5.
As an aside, I also noticed this when pressing on a text field (sharing in the off chance it is related). I did add some printout to the flutter project and it did seem like some press pressures did go over 1 which is why the assertion triggered. I did a flutter clean and they seemed to go away, but that seemed suspicious to me... Also, when I run this in the iOS emulator it doesn't appear to be an issue and the press pressure is NaN, but I'm guessing that's due to it not being an actual device.
I/flutter (20454): ══╡ EXCEPTION CAUGHT BY GESTURE LIBRARY ╞═══════════════════════════════════════════════════════════
I/flutter (20454): The following assertion was thrown while routing a pointer event:
I/flutter (20454): 'package:flutter/src/gestures/force_press.dart': Failed assertion: line 220 pos 14: 'pressure.isNaN
I/flutter (20454): ? true : (pressure <= 1.0 && pressure >= 0.0)': is not true.
I/flutter (20454):
I/flutter (20454): Either the assertion indicates an error in the framework itself, or we should provide substantially
I/flutter (20454): more information in this error message to help you determine and fix the underlying cause.
I/flutter (20454): In either case, please report this assertion by filing a bug on GitHub:
I/flutter (20454): https://github.com/flutter/flutter/issues/new?template=BUG.md
I/flutter (20454):
I/flutter (20454): When the exception was thrown, this was the stack:
I/flutter (20454): #2 ForcePressGestureRecognizer.handleEvent (package:flutter/src/gestures/force_press.dart:220:14)
I/flutter (20454): #3 PointerRouter._dispatch (package:flutter/src/gestures/pointer_router.dart:73:12)
I/flutter (20454): #4 PointerRouter.route (package:flutter/src/gestures/pointer_router.dart:101:11)
I/flutter (20454): #5 _WidgetsFlutterBinding&BindingBase&GestureBinding.handleEvent (package:flutter/src/gestures/binding.dart:180:19)
I/flutter (20454): #6 _WidgetsFlutterBinding&BindingBase&GestureBinding.dispatchEvent (package:flutter/src/gestures/binding.dart:158:22)
I/flutter (20454): #7 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerEvent (package:flutter/src/gestures/binding.dart:138:7)
I/flutter (20454): #8 _WidgetsFlutterBinding&BindingBase&GestureBinding._flushPointerEventQueue (package:flutter/src/gestures/binding.dart:101:7)
I/flutter (20454): #9 _WidgetsFlutterBinding&BindingBase&GestureBinding._handlePointerDataPacket (package:flutter/src/gestures/binding.dart:85:7)
I/flutter (20454): #13 _invoke1 (dart:ui/hooks.dart:189:10)
I/flutter (20454): #14 _dispatchPointerDataPacket (dart:ui/hooks.dart:138:5)
I/flutter (20454): (elided 5 frames from class _AssertionError and package dart:async)
I/flutter (20454):
I/flutter (20454): Event:
I/flutter (20454): PointerMoveEvent(Offset(177.1, 106.3))
I/flutter (20454): ════════════════════════════════════════════════════════════════════════════════════════════════════
And finally, I can confirm, as others have noted, that this is not present on v1.1.9. When I downgraded and reran the application on my phone, the faulty behavior is gone.
@xster The issue still happens on iOS simulator when trackpad doesn't support force touch. I suspect it also happens to older iPhone where 3D touch is not supported, but I haven't tried it out.
Repro:
Use the app in above thread #26563 (comment) iPhone XR simulator, iOS 12.1
flutter: The following assertion was thrown while dispatching a pointer event:
flutter: 'package:flutter/src/gestures/force_press.dart': Failed assertion: line 209 pos 12:
flutter: 'event.pressureMax >= 1.0': is not true.`
flutter doctor
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel dev, v1.2.2, on Mac OS X 10.13.6 17G65, locale en-GB)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.3)
[✓] Connected device (1 available)
• No issues found!
While there is no error message whatsoever, for some reason, my TextField still doesn't get focus sometimes.
Doctor summary (to see all details, run flutter doctor -v):
[✓] Flutter (Channel stable, v1.5.4-hotfix.2, on Mac OS X 10.13.6 17G7024, locale en-MG)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] iOS toolchain - develop for iOS devices (Xcode 10.1)
[✓] Android Studio (version 3.4)
[✓] VS Code (version 1.34.0)
[✓] Connected device (2 available)
• No issues found!
I'm not sure where to start, but sometimes the focus is not happening on Android, sometimes on iOS (iPad). I haven't noticed any correlation yet, and I'll report if I do.
Even forcing the CupertinoTextField to have focus like below doesn't do anything. When I keep tapping or long-pressing the text field, it just shows the Paste action, no cursor.
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.
Activity
taijuan commentedon Jan 15, 2019
Same as above
However, it happened in xiaomi phones
lariex commentedon Jan 15, 2019
switching to the dev channel can resolve the problem
hnvn commentedon Jan 15, 2019
I have to downgrade to v1.1.9
zoechi commentedon Jan 15, 2019
To investigate we would need a minimal runnable reproduction
as a single file so that we can just copy your code into
lib/main.dartof a new project and run to reproduce.ncb000gt commentedon Jan 16, 2019
@zoechi Here is something that reproduces the issue for me:
Doctor
I'm running
Android 9, kernel version4.4.116-g921edebf2ac5.As an aside, I also noticed this when pressing on a text field (sharing in the off chance it is related). I did add some printout to the flutter project and it did seem like some press pressures did go over 1 which is why the assertion triggered. I did a
flutter cleanand they seemed to go away, but that seemed suspicious to me... Also, when I run this in the iOS emulator it doesn't appear to be an issue and the press pressure isNaN, but I'm guessing that's due to it not being an actual device.And finally, I can confirm, as others have noted, that this is
notpresent onv1.1.9. When I downgraded and reran the application on my phone, the faulty behavior is gone.fhuonder commentedon Jan 16, 2019
See #24457 (comment) and #24457 (comment)
zoechi commentedon Jan 16, 2019
I can reproduce with
zoechi commentedon Jan 16, 2019
@sdolski #26624 with reference to #26628 might be related
7 remaining items
Hixie commentedon Jan 16, 2019
it's the same issue, yes. I hadn't thought through the solution at the time. I think the solution is my comment above.
jslavitz commentedon Jan 17, 2019
Ok, this is fixed now everyone! Sorry about that!
goderbauer commentedon Jan 17, 2019
@jslavitz if this is fixed, can we close the issue? Or is there more to do?
xster commentedon Jan 17, 2019
We want to follow through with the other root causes. @jslavitz: feel free to move the list of tasks to another bug though.
xster commentedon Feb 25, 2019
For posterity, this specific issue has been fixed. The last clean-up was #26659
terryl1900 commentedon Feb 27, 2019
@xster The issue still happens on iOS simulator when trackpad doesn't support force touch. I suspect it also happens to older iPhone where 3D touch is not supported, but I haven't tried it out.
Repro:
Use the app in above thread #26563 (comment)
iPhone XR simulator, iOS 12.1xster commentedon Feb 27, 2019
Sorry for the issue. That was a slightly different issue #28447 and also fixed on master head in #28478
eliezedeck commentedon Jun 2, 2019
While there is no error message whatsoever, for some reason, my TextField still doesn't get focus sometimes.
I'm not sure where to start, but sometimes the focus is not happening on Android, sometimes on iOS (iPad). I haven't noticed any correlation yet, and I'll report if I do.
eliezedeck commentedon Jun 3, 2019
Even forcing the
CupertinoTextFieldto have focus like below doesn't do anything. When I keep tapping or long-pressing the text field, it just shows the Paste action, no cursor.Here is how I'm forcing the focus:
The
forced focus!is printed alright, but no cursor on the text field.eliezedeck commentedon Jun 3, 2019
Problem solved, after using Flutter v1.6.3 (beta channel).
bianxiang commentedon Jan 17, 2020
I use Flutter v1.12.13,how can I fix it?
github-actions commentedon Aug 23, 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.