-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Closed
Labels
a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemse: web_htmlHTML rendering backend for WebHTML rendering backend for Webengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 1.24Found to occur in 1.24Found to occur in 1.24frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyWeb applications specifically
Description
I'm creating a custom TextEditingController to support for different styles within a single textfield. So I have overridden the ### buildTextSpan function in a child class of TextEditingController like this:
class NewTextEditingController extends TextEditingController {
NewTextEditingController({String text})
: assert(text != null),
super(text: text);
@override
TextSpan buildTextSpan({TextStyle style, bool withComposing}) {
return TextSpan(
children: [TextSpan(text: text.substring(0, 2)),
TextSpan(text: text.substring(2),style: TextStyle(fontWeight: FontWeight.w700))], style: style);
}
}
This controller just displays the first letters of the textfield as regular weight and the remaining part as bold.
Then I modified the _MyHomePageState class in the default application to have a textfield in a listview like this:
class _MyHomePageState extends State<MyHomePage> {
NewTextEditingController controller = new NewTextEditingController(text: "test");
@override
Widget build(BuildContext context) {
return Scaffold(
body: Material(
color: Colors.white,
child: ListView(
children: [
TextField(
controller: controller,
)
],
),
),
);
}
}
And while on mobile it works just fine:

On web the cursor doesn't move from the initial position (0) and the text just gets added at the end. Selection is also not possible.
Futter doctor:
Doctor summary (to see all details, run flutter doctor -v):
[√] Flutter (Channel master, 1.24.0-2.0.pre.86, on Microsoft Windows [Version ], locale en-US)
[√] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[√] Chrome - develop for the web
[√] Visual Studio - develop for Windows (Visual Studio Community 2019 16.5.4)
[√] Android Studio (version 4.0)
[√] VS Code, 64-bit edition (version 1.49.3)
[√] Connected device (3 available)
• No issues found!
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
a: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemse: web_htmlHTML rendering backend for WebHTML rendering backend for Webengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.f: material designflutter/packages/flutter/material repository.flutter/packages/flutter/material repository.found in release: 1.24Found to occur in 1.24Found to occur in 1.24frameworkflutter/packages/flutter repository. See also f: labels.flutter/packages/flutter repository. See also f: labels.has reproducible stepsThe issue has been confirmed reproducible and is ready to work onThe issue has been confirmed reproducible and is ready to work onplatform-webWeb applications specificallyWeb applications specifically