Skip to content

Commit d57ea48

Browse files
Remove an assert with false positives (#148795)
Fixes flutter/flutter#110343. This is not an important piece of guardrail and the iOS embedder only expects best-effort results anyways.
1 parent b2eda06 commit d57ea48

File tree

2 files changed

+31
-1
lines changed

2 files changed

+31
-1
lines changed

packages/flutter/lib/src/widgets/editable_text.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4494,7 +4494,6 @@ class EditableTextState extends State<EditableText> with AutomaticKeepAliveClien
44944494
Rect? composingRect = renderEditable.getRectForComposingRange(composingRange);
44954495
// Send the caret location instead if there's no marked text yet.
44964496
if (composingRect == null) {
4497-
assert(!composingRange.isValid || composingRange.isCollapsed);
44984497
final int offset = composingRange.isValid ? composingRange.start : 0;
44994498
composingRect = renderEditable.getLocalRectForCaret(TextPosition(offset: offset));
45004499
}

packages/flutter/test/widgets/editable_text_test.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17548,6 +17548,37 @@ void main() {
1754817548
const TextSelection.collapsed(offset: 17, affinity: TextAffinity.upstream),
1754917549
);
1755017550
});
17551+
17552+
testWidgets('Composing region can truncate grapheme', (WidgetTester tester) async {
17553+
await tester.pumpWidget(
17554+
MediaQuery(
17555+
data: const MediaQueryData(),
17556+
child: Directionality(
17557+
textDirection: TextDirection.ltr,
17558+
child: EditableText(
17559+
autofocus: true,
17560+
backgroundCursorColor: Colors.grey,
17561+
controller: controller,
17562+
focusNode: focusNode,
17563+
style: textStyle,
17564+
cursorColor: cursorColor,
17565+
),
17566+
),
17567+
),
17568+
);
17569+
17570+
await tester.pumpAndSettle();
17571+
assert(focusNode.hasFocus);
17572+
17573+
controller.value = const TextEditingValue(
17574+
text: 'Á',
17575+
selection: TextSelection(baseOffset: 1, extentOffset: 2),
17576+
composing: TextSelection(baseOffset: 1, extentOffset: 2),
17577+
);
17578+
await tester.pumpAndSettle();
17579+
17580+
expect(tester.takeException(), isNull);
17581+
});
1755117582
}
1755217583

1755317584
class UnsettableController extends TextEditingController {

0 commit comments

Comments
 (0)