The `WidgetTester.enterText` and `TestTextInput.enterText` methods now move the caret to the end of the input text.
Original behavior
The caret indicates the insertion point within the current text in an active input field. Typically, when a new character is entered, the caret stays immediately after it. In Flutter the caret position is represented by a collapsed selection. When the selection is invalid, usually the user won't be able to modify or add text until they change the selection to a valid value.
New behavior
In addition to replacing the text with the supplied text, `WidgetTester.enterText` and `TestTextInput.enterText` now set the selection to `TextSelection.collapsed(offset: text.length)`, instead of `TextSelection.collapsed(offset: -1)`.
- Who is affected
- Applications and packages relying on the previous behaviour or signature. Code that uses WidgetTester.enterText, TestTextInput.enterText, TextEditingValue.selection and related APIs.
- Practical impact
- Behaviour or API differences that can break builds or change runtime behaviour.
- What action should I take?
- Follow the official migration guide below, update affected call sites, run `dart fix --apply` where a fix is available, then run your tests.
Before and after (from the official guide)
| 1 | − | await testTextInput.enterText(text); |
| 1 | + | await testTextInput.updateEditingValue(TextEditingValue( |
| 2 | + | text: text, |
| 3 | + | )); |
Raw before / after
await testTextInput.enterText(text);
await testTextInput.updateEditingValue(TextEditingValue( text: text, ));
Official migration guide (excerpt, © The Flutter Authors, CC BY 3.0)
It should be very uncommon for tests to have to rely on the
previous behavior of enterText, since usually the selection
should not be invalid. Consider changing the expected values of
your tests to adopt the enterText change.
Common test failures this change may introduce includes:
-
Golden test failures:
The caret appears at the end of the text, as opposed to before the text prior to the change.
-
Different
TextEditingValue.selectionafter callingenterText:The text field's
TextEditingValuenow has a collapsed selection with a non-negative offset, as opposed toTextSelection.collapsed(offset: -1)prior to the change. For instance, you may seeexpect(controller.value.selection.baseOffset, -1);failing afterenterTextcalls.
If your tests have to rely on setting the selection to invalid,
the previous behavior can be achieved usingupdateEditingValue:
TestTextInput.enterText
Code before migration:
await testTextInput.enterText(text);Code after migration:
await testTextInput.updateEditingValue(TextEditingValue(
text: text,
));WidgetTester.enterText
Code before migration:
await tester.enterText(finder, text);Code after migration:
await tester.showKeyboard(finder);
await tester.updateEditingValue(TextEditingValue(
text: text,
));
await tester.idle();AI_PROVIDER (for example to openai-compatible with a local Ollama or LM Studio endpoint) to enable grounded explanations. Everything else on this page works without an AI provider.Listed in the official breaking-changes index (docs.flutter.dev/release/breaking-changes).
An official announcement or migration guide documents an intended behaviour or API change. A verified source change (git diff) shows code changed but does not by itself prove a public API is breaking. AI interpretations are labelled and never used to classify a change.
- Official migration guide
- WidgetTester.enterText
- TestTextInput.enterText
- Issue 79494
- enterText to move the caret to the end
- Source commit
- b3045439b7c0
- Source last updated
- Oct 21, 2026
- Last synchronized
- Oct 21, 2026
- Publication status
- published
Publication history
- Oct 21, 2026, 8:31 PM: new → published (ingestion) — Backed by an official breaking-change/migration guide.
AI_PROVIDER (for example to openai-compatible with a local Ollama or LM Studio endpoint) to enable grounded explanations. Everything else on this page works without an AI provider.