Closed xErik closed 1 month ago
@xErik
This error readOnly && !obscureText is not true
.
You need add attribute readOnly
or obscureText
in your TextField
widget
Hi @xErik, this looks similar to https://github.com/flutter/flutter/issues/97433 so I will close this issue as a duplicate, please follow it for further updates.
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.
Steps to reproduce
Detecting a tapped
TextSpan
insideTextField
usingTapGestureRecognizer
results in anException
.Expected results
TapGestureRecognizer.onTap()
should be called correctly.Actual results
Throws exception.
Code sample
Code sample
```dart import 'package:flutter/gestures.dart'; import 'package:flutter/material.dart'; void main() { runApp(const MyApp()); } class MyApp extends StatelessWidget { const MyApp({super.key}); @override Widget build(BuildContext context) { return MaterialApp( debugShowCheckedModeBanner: false, home: SafeArea( child: Scaffold( body: TextField( controller: GestureTexteditingController(), ), ), ), ); } } class GestureTexteditingController extends TextEditingController { /// Builds [TextSpan] from current editing value. @override TextSpan buildTextSpan({ TextStyle? style, required BuildContext context, required bool withComposing, }) { ListScreenshots or Video
No response
Logs
Logs
```console ══╡ EXCEPTION CAUGHT BY WIDGETS LIBRARY ╞═══════════════════════════════════════════════════════════ The following assertion was thrown building _ScribbleFocusable(state: _ScribbleFocusableState#87785): Assertion failed: file:///C:/Users/Erik/flutter/packages/flutter/lib/src/rendering/editable.dart:1318:14 readOnly && !obscureText is not true The relevant error-causing widget was: TextField TextField:file:///C:/Users/Erik/rich_text_controller/example/flutter_example/lib/main.dart:17:17 When the exception was thrown, this was the stack: dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 296:3 throw_ dart-sdk/lib/_internal/js_dev_runtime/private/ddc_runtime/errors.dart 29:3 assertFailed packages/flutter/src/rendering/editable.dart 1318:27 describeSemanticsConfiguration packages/flutter/src/rendering/object.dart 3487:7 get [_semanticsConfiguration] packages/flutter/src/rendering/object.dart 2148:58 attach packages/flutter/src/rendering/object.dart 4472:11 attach packages/flutter/src/rendering/object.dart 4340:11 attach packages/flutter/src/rendering/editable.dart 1621:11 attach packages/flutter/src/rendering/object.dart 1841:12 adoptChild packages/flutter/src/rendering/object.dart 4057:7 set child packages/flutter/src/widgets/framework.dart 6784:17 insertRenderObjectChild packages/flutter/src/widgets/framework.dart 6602:35 attachRenderObject packages/flutter/src/widgets/framework.dart 6467:5 mount ```Flutter Doctor output
Doctor output
```console PS C:\Users\Erik\rich_text_controller> flutter doctor -v [√] Flutter (Channel stable, 3.22.3, on Microsoft Windows [Version 10.0.19045.4651], locale en-DE) • Flutter version 3.22.3 on channel stable at C:\Users\bla\flutter • Upstream repository https://github.com/flutter/flutter.git • Framework revision b0850beeb2 (2 weeks ago), 2024-07-16 21:43:41 -0700 • Engine revision 235db911ba • Dart version 3.4.4 • DevTools version 2.34.3 [√] Windows Version (Installed version of Windows is version 10 or higher) [√] Android toolchain - develop for Android devices (Android SDK version 33.0.2) • Android SDK at C:\Users\Erik\AppData\Local\Android\sdk • Platform android-34, build-tools 33.0.2 • Java binary at: C:\Program Files\Android\Android Studio\jbr\bin\java • Java version OpenJDK Runtime Environment (build 17.0.6+0-b2043.56-9586694) • All Android licenses accepted. [√] Chrome - develop for the web • Chrome at C:\Program Files\Google\Chrome\Application\chrome.exe [√] Visual Studio - develop Windows apps (Visual Studio Community 2022 17.4.4) • Visual Studio at C:\Program Files\Microsoft Visual Studio\2022\Community • Visual Studio Community 2022 version 17.4.33213.308 • Windows 10 SDK version 10.0.22000.0 [√] Android Studio (version 2022.2) • Android Studio at C:\Program Files\Android\Android Studio • 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-b2043.56-9586694) [√] VS Code (version 1.91.1) • VS Code at C:\Users\Erik\AppData\Local\Programs\Microsoft VS Code • Flutter extension version 3.92.0 [√] Connected device (3 available) • Windows (desktop) • windows • windows-x64 • Microsoft Windows [Version 10.0.19045.4651] • Chrome (web) • chrome • web-javascript • Google Chrome 127.0.6533.88 • Edge (web) • edge • web-javascript • Microsoft Edge 126.0.2592.113 [√] Network resources • All expected network resources are available. • No issues found! ```