Skip to content
Boring Doc
BreakingHigh impactOfficial migration guidesince 2.5.0landed 2.1.0-13.0.pre

Change the enterText method to move the caret to the end of the input text

Framework · Official source

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)

dart+3−1
Before
1−await testTextInput.enterText(text);
 
 
After
1+await testTextInput.updateEditingValue(TextEditingValue(
2+ text: text,
3+));
Raw before / after
await testTextInput.enterText(text);
await testTextInput.updateEditingValue(TextEditingValue(
  text: text,
));
Migration checklist0/2
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.selection after calling enterText:

    The text field's TextEditingValue now has a collapsed selection with a non-negative offset, as opposed to TextSelection.collapsed(offset: -1) prior to the change. For instance, you may see expect(controller.value.selection.baseOffset, -1); failing after enterText calls.

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();
Migration assistantAI-generated · grounded in cited sources
AI explanations are not configured
Set 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.
Official migration guide·Verified classification (95%)

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.

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 explanationAI-generated · grounded in cited sources
AI explanations are not configured
Set 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.
Was this useful?
Change the enterText method to move the caret to the end of the input text · Boring Doc