Reorder show and setEditingState calls to the IMM (#43865)
This commit is contained in:
@@ -1409,6 +1409,7 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
|
||||
keyboardAppearance: widget.keyboardAppearance,
|
||||
),
|
||||
);
|
||||
_textInputConnection.show();
|
||||
|
||||
_updateSizeAndTransform();
|
||||
final TextStyle style = widget.style;
|
||||
@@ -1421,8 +1422,9 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
|
||||
textAlign: widget.textAlign,
|
||||
)
|
||||
..setEditingState(localValue);
|
||||
} else {
|
||||
_textInputConnection.show();
|
||||
}
|
||||
_textInputConnection.show();
|
||||
}
|
||||
|
||||
void _closeInputConnectionIfNeeded() {
|
||||
|
||||
@@ -3413,6 +3413,45 @@ void main() {
|
||||
throwsAssertionError,
|
||||
);
|
||||
});
|
||||
|
||||
testWidgets('input imm channel calls are ordered correctly', (WidgetTester tester) async {
|
||||
final List<MethodCall> log = <MethodCall>[];
|
||||
SystemChannels.textInput.setMockMethodCallHandler((MethodCall methodCall) async {
|
||||
log.add(methodCall);
|
||||
});
|
||||
const String testText = 'flutter is the best!';
|
||||
final TextEditingController controller = TextEditingController(text: testText);
|
||||
final EditableText et = EditableText(
|
||||
showSelectionHandles: true,
|
||||
maxLines: 2,
|
||||
controller: controller,
|
||||
focusNode: FocusNode(),
|
||||
cursorColor: Colors.red,
|
||||
backgroundCursorColor: Colors.blue,
|
||||
style: Typography(platform: TargetPlatform.android).black.subhead.copyWith(fontFamily: 'Roboto'),
|
||||
keyboardType: TextInputType.text,
|
||||
);
|
||||
|
||||
await tester.pumpWidget(MaterialApp(
|
||||
home: Align(
|
||||
alignment: Alignment.topLeft,
|
||||
child: SizedBox(
|
||||
width: 100,
|
||||
child: et,
|
||||
),
|
||||
),
|
||||
));
|
||||
|
||||
await tester.showKeyboard(find.byType(EditableText));
|
||||
expect(log.length, 7);
|
||||
// TextInput.show should be before TextInput.setEditingState
|
||||
final List<String> logOrder = <String>['TextInput.setClient', 'TextInput.show', 'TextInput.setEditableSizeAndTransform', 'TextInput.setStyle', 'TextInput.setEditingState', 'TextInput.setEditingState', 'TextInput.show'];
|
||||
int index = 0;
|
||||
for (MethodCall m in log) {
|
||||
expect(m.method, logOrder[index]);
|
||||
index++;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
class MockTextSelectionControls extends Mock implements TextSelectionControls {
|
||||
|
||||
Reference in New Issue
Block a user