Unverified Commit 8caa14e6 authored by LongCatIsLooong's avatar LongCatIsLooong Committed by GitHub

Fix a type casting error in text_input.dart (#109635)

parent 3d94a014
......@@ -1523,7 +1523,7 @@ RawFloatingCursorPoint _toTextPoint(FloatingCursorDragState state, Map<String, d
assert(encoded['X'] != null, 'You must provide a value for the horizontal location of the floating cursor.');
assert(encoded['Y'] != null, 'You must provide a value for the vertical location of the floating cursor.');
final Offset offset = state == FloatingCursorDragState.Update
? Offset(encoded['X'] as double, encoded['Y'] as double)
? Offset((encoded['X'] as num).toDouble(), (encoded['Y'] as num).toDouble())
: Offset.zero;
return RawFloatingCursorPoint(offset: offset, state: state);
}
......
......@@ -241,6 +241,33 @@ void main() {
expect(record[0].exception.toString(), matches(RegExp(r'\brange.start >= 0 && range.start <= text.length\b')));
expect(record[0].exception.toString(), matches(RegExp(r'\bRange start 2 is out of text of length 1\b')));
});
test('FloatingCursor coordinates type-casting', () async {
// Regression test for https://github.com/flutter/flutter/issues/109632.
final List<FlutterErrorDetails> errors = <FlutterErrorDetails>[];
FlutterError.onError = errors.add;
final FakeTextInputClient client = FakeTextInputClient(const TextEditingValue(text: 'test3'));
const TextInputConfiguration configuration = TextInputConfiguration();
TextInput.attach(client, configuration);
final ByteData? messageBytes = const JSONMessageCodec().encodeMessage(<String, dynamic>{
'method': 'TextInputClient.updateFloatingCursor',
'args': <dynamic>[
-1,
'FloatingCursorDragState.update',
<String, dynamic>{ 'X': 2, 'Y': 3 },
],
});
await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage(
'flutter/textinput',
messageBytes,
(ByteData? _) {},
);
expect(errors, isEmpty);
});
});
group('TextInputConfiguration', () {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment