-
Notifications
You must be signed in to change notification settings - Fork 30.1k
Closed
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 1.22Found to occur in 1.22Found to occur in 1.22frameworkflutter/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 onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version
Description
@justinmc Hi,
This is the track for #65754 (comment)
Step to reproduce
There are some differences between the real device and the simulator, but both of them will repeatedly notify the same value.
Real device, OPPO, Reno3, Sogou input.
1, Run the app, focus the textField, switch to numeric keyboard, input any number will trigger.
I/flutter (30312): updateEditingValue [TextEditingValue(text: ┤I love flutter!1├, selection: TextSelection(baseOffset: 16, extentOffset: 16, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))]
I/flutter (30312): Second text field: I love flutter!1
I/flutter (30312): updateEditingValue [TextEditingValue(text: ┤I love flutter!1├, selection: TextSelection(baseOffset: 16, extentOffset: 16, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))]
I/flutter (30312): updateEditingValue [TextEditingValue(text: ┤I love flutter!12├, selection: TextSelection(baseOffset: 17, extentOffset: 17, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))]
I/flutter (30312): Second text field: I love flutter!12
I/flutter (30312): updateEditingValue [TextEditingValue(text: ┤I love flutter!12├, selection: TextSelection(baseOffset: 17, extentOffset: 17, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))]
Simulator, Chinese language.
1, Run the app, clean the textField, switch to numeric keyboard, input one number
2, Delete the number will trigger the issue

I/flutter (17052): updateEditingValue [TextEditingValue(text: ┤├, selection: TextSelection(baseOffset: 0, extentOffset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))]
I/flutter (17052): Second text field:
I/flutter (17052): updateEditingValue [TextEditingValue(text: ┤├, selection: TextSelection(baseOffset: 0, extentOffset: 0, affinity: TextAffinity.downstream, isDirectional: false), composing: TextRange(start: -1, end: -1))]
Sample Code
import 'package:flutter/material.dart';
import 'package:flutter/services.dart';
void main() => runApp(MyApp());
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
title: 'Retrieve Text Input',
home: MyCustomForm(),
);
}
}
// Define a custom Form widget.
class MyCustomForm extends StatefulWidget {
@override
_MyCustomFormState createState() => _MyCustomFormState();
}
// Define a corresponding State class.
// This class holds data related to the Form.
class _MyCustomFormState extends State<MyCustomForm> {
// Create a text controller and use it to retrieve the current value
// of the TextField.
final myController = TextEditingController(text: 'I love flutter!');
final newController = TextEditingController(text: 'I am a new controller.');
TextEditingController _controller;
@override
void initState() {
super.initState();
_controller = myController;
_controller.addListener(_printLatestValue);
}
@override
void dispose() {
// Clean up the controller when the widget is removed from the widget tree.
// This also removes the _printLatestValue listener.
myController.dispose();
newController.dispose();
super.dispose();
}
_printLatestValue() {
print("Second text field: ${myController.text}");
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('Retrieve Text Input'),
),
body: Padding(
padding: const EdgeInsets.all(16.0),
child: Column(
children: <Widget>[
// TextField(
// onChanged: (text) {
// print("First text field: $text");
// },
// ),
TextField(
controller: _controller,
keyboardType: TextInputType.multiline,
maxLines: 7,
// inputFormatters: [LengthLimitingTextInputFormatter(3)],
),
MaterialButton(
child: Text("set to '123'"),
onPressed: () {
setState(() {
_controller.value = TextEditingValue(
text: '123',
composing:TextRange(start: -1, end: -1),
selection: TextSelection(
baseOffset: 3,
extentOffset: 3,
affinity: TextAffinity.downstream,
isDirectional: false));
});
}),
MaterialButton(
child: Text("set to '12'"),
onPressed: () {
setState(() {
_controller.text = '12';
});
}),
MaterialButton(
child: Text('change controller'),
onPressed: () {
setState(() {
_controller = newController;
});
}),
],
),
),
);
}
}
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
P2Important issues not at the top of the work listImportant issues not at the top of the work lista: text inputEntering text in a text field or keyboard related problemsEntering text in a text field or keyboard related problemsengineflutter/engine related. See also e: labels.flutter/engine related. See also e: labels.found in release: 1.22Found to occur in 1.22Found to occur in 1.22frameworkflutter/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 onr: fixedIssue is closed as already fixed in a newer versionIssue is closed as already fixed in a newer version