From 8caa14e6291667a972936ebc210380995e82f5df Mon Sep 17 00:00:00 2001 From: LongCatIsLooong <31859944+LongCatIsLooong@users.noreply.github.com> Date: Tue, 16 Aug 2022 18:26:21 -0700 Subject: [PATCH] Fix a type casting error in text_input.dart (#109635) --- .../flutter/lib/src/services/text_input.dart | 2 +- .../test/services/text_input_test.dart | 27 +++++++++++++++++++ 2 files changed, 28 insertions(+), 1 deletion(-) diff --git a/packages/flutter/lib/src/services/text_input.dart b/packages/flutter/lib/src/services/text_input.dart index 50f0631e0e..937d97dffd 100644 --- a/packages/flutter/lib/src/services/text_input.dart +++ b/packages/flutter/lib/src/services/text_input.dart @@ -1523,7 +1523,7 @@ RawFloatingCursorPoint _toTextPoint(FloatingCursorDragState state, Map= 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 errors = []; + 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({ + 'method': 'TextInputClient.updateFloatingCursor', + 'args': [ + -1, + 'FloatingCursorDragState.update', + { 'X': 2, 'Y': 3 }, + ], + }); + + await ServicesBinding.instance.defaultBinaryMessenger.handlePlatformMessage( + 'flutter/textinput', + messageBytes, + (ByteData? _) {}, + ); + + expect(errors, isEmpty); + }); }); group('TextInputConfiguration', () {