diff --git a/packages/flutter/lib/src/widgets/editable_text.dart b/packages/flutter/lib/src/widgets/editable_text.dart index 069230666e9f..08487b5d2af0 100644 --- a/packages/flutter/lib/src/widgets/editable_text.dart +++ b/packages/flutter/lib/src/widgets/editable_text.dart @@ -4494,7 +4494,6 @@ class EditableTextState extends State with AutomaticKeepAliveClien Rect? composingRect = renderEditable.getRectForComposingRange(composingRange); // Send the caret location instead if there's no marked text yet. if (composingRect == null) { - assert(!composingRange.isValid || composingRange.isCollapsed); final int offset = composingRange.isValid ? composingRange.start : 0; composingRect = renderEditable.getLocalRectForCaret(TextPosition(offset: offset)); } diff --git a/packages/flutter/test/widgets/editable_text_test.dart b/packages/flutter/test/widgets/editable_text_test.dart index 8c031c4a17ff..ab260f8a3cf6 100644 --- a/packages/flutter/test/widgets/editable_text_test.dart +++ b/packages/flutter/test/widgets/editable_text_test.dart @@ -17548,6 +17548,37 @@ void main() { const TextSelection.collapsed(offset: 17, affinity: TextAffinity.upstream), ); }); + + testWidgets('Composing region can truncate grapheme', (WidgetTester tester) async { + await tester.pumpWidget( + MediaQuery( + data: const MediaQueryData(), + child: Directionality( + textDirection: TextDirection.ltr, + child: EditableText( + autofocus: true, + backgroundCursorColor: Colors.grey, + controller: controller, + focusNode: focusNode, + style: textStyle, + cursorColor: cursorColor, + ), + ), + ), + ); + + await tester.pumpAndSettle(); + assert(focusNode.hasFocus); + + controller.value = const TextEditingValue( + text: 'Á', + selection: TextSelection(baseOffset: 1, extentOffset: 2), + composing: TextSelection(baseOffset: 1, extentOffset: 2), + ); + await tester.pumpAndSettle(); + + expect(tester.takeException(), isNull); + }); } class UnsettableController extends TextEditingController {