The engine notify twice for the same value when use numeric keyboard input #65811
Copy link
Copy link
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
Activity
TahaTesser commentedon Sep 15, 2020
Hi @xu-baolin
I am unable to print
updateEditingValueusing your code sample, does this require more than just your code sample?xu-baolin commentedon Sep 15, 2020
you should add log in function 'updateEditingValue'.
TahaTesser commentedon Sep 15, 2020
logs
code sample
flutter doctor -v
[✓] Flutter (Channel master, 1.22.0-10.0.pre.176, on Mac OS X 10.15.6 19G2021, locale en-GB) • Flutter version 1.22.0-10.0.pre.176 at /Users/tahatesser/Code/flutter_master • Framework revision 96ca0e272b (3 hours ago), 2020-09-15 09:02:04 +0100 • Engine revision 7e962ba911 • Dart version 2.10.0 (build 2.10.0-124.0.dev) [✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/tahatesser/Code/sdk • Platform android-30, build-tools 30.0.2 • ANDROID_HOME = /Users/tahatesser/Code/sdk • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) • All Android licenses accepted. [✓] Xcode - develop for iOS and macOS (Xcode 11.7) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 11.7, Build version 11E801a • CocoaPods version 1.9.3 [✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome [✓] Android Studio (version 4.0) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin version 49.0.2 • Dart plugin version 193.7547 • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593) [✓] VS Code (version 1.49.0) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.14.1 [✓] Connected device (4 available) • RMX2001 (mobile) • EUYTFEUSQSRGDA6D • android-arm64 • Android 10 (API 29) • macOS (desktop) • macos • darwin-x64 • Mac OS X 10.15.6 19G2021 • Web Server (web) • web-server • web-javascript • Flutter Tools • Chrome (web) • chrome • web-javascript • Google Chrome 85.0.4183.102 • No issues found!goderbauer commentedon Sep 16, 2020
/cc @justinmc
maheshj01 commentedon Jan 10, 2023
Hi @xu-baolin, I verified the issue on stable and the master channel with Pinyin input on Xiaomi Redmi k20 pro with Gboard and I am unable to reproduce the issue. I believe this issue is fixed.
Screen.Recording.2023-01-09.at.11.03.51.PM.mov
code sample
flutter doctor -v (mac)
Closing as fixed. Incase you still encounter the issue then please feel free to write in the comments and we will reopen it.
github-actions commentedon Mar 4, 2023
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.