flutter / flutter

Flutter makes it easy and fast to build beautiful apps for mobile and beyond
https://flutter.dev
BSD 3-Clause "New" or "Revised" License
166.75k stars 27.63k forks source link

[Cupertino]: CupertinoTextField with `TextAlign.right` throws `Failed assertion: line 206 pos 12: 'isValid': is not true.` #139201

Open optimisme opened 1 year ago

optimisme commented 1 year ago

Is there an existing issue for this?

Steps to reproduce

Create a CupertinoTextField object with TextAlign.right, enter a text with several letters, and press the up and down keys to go to the beginning or end of the text.

Expected results

The cursor moving at the beginning or end of the text.

Actual results

This message:

══╡ EXCEPTION CAUGHT BY SERVICES LIBRARY ╞══════════════════════════════════════════════════════════
The following assertion was thrown during method call TextInputClient.performSelectors:
'package:flutter/src/rendering/editable.dart': Failed assertion: line 206 pos 12: 'isValid': is not
true.

Either the assertion indicates an error in the framework itself, or we should provide substantially
more information in this error message to help you determine and fix the underlying cause.
In either case, please report this assertion by filing a bug on GitHub:
  https://github.com/flutter/flutter/issues/new?template=2_bug.yml

When the exception was thrown, this was the stack:
#2      VerticalCaretMovementRun.movePrevious (package:flutter/src/rendering/editable.dart:206:12)
#3      _UpdateTextSelectionVerticallyAction.invoke (package:flutter/src/widgets/editable_text.dart:5557:61)
#4      _OverridableContextAction.invokeDefaultAction (package:flutter/src/widgets/actions.dart:1811:28)
#5      _OverridableActionMixin.invoke (package:flutter/src/widgets/actions.dart:1676:9)
#6      Action._invoke (package:flutter/src/widgets/actions.dart:336:19)
#7      ActionDispatcher.invokeAction (package:flutter/src/widgets/actions.dart:641:19)
#8      Actions.invoke.<anonymous closure> (package:flutter/src/widgets/actions.dart:963:48)
#9      Actions._visitActionsAncestors (package:flutter/src/widgets/actions.dart:745:18)
#10     Actions.invoke (package:flutter/src/widgets/actions.dart:957:30)
#11     EditableTextState.performSelector (package:flutter/src/widgets/editable_text.dart:4347:17)
#12     ListBase.forEach (dart:collection/list.dart:51:13)
#13     TextInput._handleTextInputInvocation (package:flutter/src/services/text_input.dart:1880:19)
#14     TextInput._loudlyHandleTextInputInvocation (package:flutter/src/services/text_input.dart:1759:20)
#15     MethodChannel._handleAsMethodCall (package:flutter/src/services/platform_channel.dart:559:55)
#16     MethodChannel.setMethodCallHandler.<anonymous closure> (package:flutter/src/services/platform_channel.dart:552:34)
#17     _DefaultBinaryMessenger.setMessageHandler.<anonymous closure> (package:flutter/src/services/binding.dart:567:35)
#18     _invoke2 (dart:ui/hooks.dart:344:13)
#19     _ChannelCallbackRecord.invoke (dart:ui/channel_buffers.dart:45:5)
#20     _Channel.push (dart:ui/channel_buffers.dart:135:31)
#21     ChannelBuffers.push (dart:ui/channel_buffers.dart:343:17)
#22     PlatformDispatcher._dispatchPlatformMessage (dart:ui/platform_dispatcher.dart:722:22)
#23     _dispatchPlatformMessage (dart:ui/hooks.dart:257:31)
(elided 2 frames from class _AssertionError)

Code sample

Code sample ```dart CupertinoTextField( textAlign: TextAlign.right, controller: widget.controller, ) ```

Screenshots or Video

Screenshots / Video demonstration [Upload media here]

Logs

Logs ```console [Paste your logs here] ```

Flutter Doctor output

Doctor output ```console [✓] Flutter (Channel stable, 3.16.1, on macOS 14.0 23A344 darwin-arm64, locale en-ES) [!] Android toolchain - develop for Android devices (Android SDK version 33.0.2) ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 15.0.1) [✓] Chrome - develop for the web [✓] Android Studio (version 2021.3) [✓] VS Code (version 1.84.2) [✓] VS Code (version 1.85.0-insider) [✓] Connected device (2 available) [✓] Network resources ! Doctor found issues in 1 category. ```
darshankawar commented 1 year ago

Thanks for the report @optimisme I was able to replicate the reported error and it seems to be only occuring when using textAlign: right

stable, master flutter doctor -v ``` [!] Flutter (Channel stable, 3.16.0, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.16.0 on channel stable at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision db7ef5bf9f (12 days ago), 2023-11-15 11:25:44 -0800 • Engine revision 74d16627b9 • Dart version 3.2.0 • DevTools version 2.28.2 • If those were intentional, you can disregard the above warnings; however it is recommended to use "git" directly to perform update checks and upgrades. [!] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (5 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. [!] Flutter (Channel master, 3.17.0-17.0.pre.49, on macOS 12.2.1 21D62 darwin-x64, locale en-GB) • Flutter version 3.17.0-17.0.pre.49 on channel master at /Users/dhs/documents/fluttersdk/flutter ! Warning: `flutter` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/flutter, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. ! Warning: `dart` on your path resolves to /Users/dhs/Documents/Fluttersdk/flutter/bin/dart, which is not inside your current Flutter SDK checkout at /Users/dhs/documents/fluttersdk/flutter. Consider adding /Users/dhs/documents/fluttersdk/flutter/bin to the front of your path. • Upstream repository https://github.com/flutter/flutter.git • Framework revision 0233e93853 (61 minutes ago), 2023-11-28 23:30:21 -0500 • Engine revision 9a840e8dba • Dart version 3.3.0 (build 3.3.0-170.0.dev) • DevTools version 2.30.0-dev.4 • 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 30.0.3) • Android SDK at /Users/dhs/Library/Android/sdk ✗ cmdline-tools component is missing Run `path/to/sdkmanager --install "cmdline-tools;latest"` See https://developer.android.com/studio/command-line for more details. ✗ Android license status unknown. Run `flutter doctor --android-licenses` to accept the SDK licenses. See https://flutter.dev/docs/get-started/install/macos#android-setup for more details. [✓] Xcode - develop for iOS and macOS (Xcode 13.2.1) • Xcode at /Applications/Xcode.app/Contents/Developer • Build 13C100 • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] IntelliJ IDEA Ultimate Edition (version 2021.3.2) • IntelliJ at /Applications/IntelliJ IDEA.app • Flutter plugin version 65.1.4 • Dart plugin version 213.7228 [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.29.0 [✓] Connected device (3 available) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 15.3.1 19D52 • macOS (desktop) • macos • darwin-x64 • macOS 12.2.1 21D62 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 109.0.5414.119 [✓] Network resources • All expected network resources are available. ! Doctor found issues in 1 category. [!] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer ! Flutter recommends a minimum Xcode version of 13. Download the latest version or update via the Mac App Store. • CocoaPods version 1.11.2 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] VS Code (version 1.62.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.21.0 [✓] Connected device (5 available) • SM G975F (mobile) • RZ8M802WY0X • android-arm64 • Android 11 (API 30) • Darshan's iphone (mobile) • 21150b119064aecc249dfcfe05e259197461ce23 • ios • iOS 14.4.1 18D61 • iPhone 12 Pro Max (mobile) • A5473606-0213-4FD8-BA16-553433949729 • ios • com.apple.CoreSimulator.SimRuntime.iOS-14-3 (simulator) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.4 19E2269 darwin-x64 • Chrome (web) • chrome • web-javascript • Google Chrome 98.0.4758.80 [✓] HTTP Host Availability • All required HTTP hosts are available ! Doctor found issues in 1 category. ```

There's another related issue logged, but for desktop: https://github.com/flutter/flutter/issues/139196

LongCatIsLooong commented 11 months ago

The current VerticalCaretMovementRun implementation relies on some implementation detail because we had no proper way to determine if the underlying text layout has changed. Let me see if I can remove the isValid check.

flutter-triage-bot[bot] commented 7 months ago

This issue is assigned to @LongCatIsLooong but has had no recent status updates. Please consider unassigning this issue if it is not going to be addressed in the near future. This allows people to have a clearer picture of what work is actually planned. Thanks!

flutter-triage-bot[bot] commented 4 months ago

This issue was assigned to @LongCatIsLooong but has had no status updates in a long time. To remove any ambiguity about whether the issue is being worked on, the assignee was removed.

justinmc commented 4 months ago

CC @LongCatIsLooong from triage, you wanted to follow up on your comment above and add some details if you have any.

Hanibachi commented 3 months ago

how come something as crucial as this isn't being fixed