Skip to content
Boring Doc
BreakingHigh impactOfficial migration guidesince 2.0.0landed 1.23.0-4.0.pre

TextSelectionTheme migration

Framework · Official source

The `ThemeData` properties that controlled the look of selected text in Material widgets have been moved into their own `TextSelectionTheme`. These properties include `cursorColor`, `textSelectionColor`, and `textSelectionHandleColor`. The defaults for these properties have also been changed to match the Material Design specification.

Original behavior

As part of the larger Material Theme Updates, we have introduced a new Text Selection Theme used to specify the properties of selected text in `TextField` and `SelectableText` widgets. These replace several top-level properties of `ThemeData` and update their default values to match the Material Design specification. This document describes how applications can migrate to this new API.

New behavior

Not stated in the source.

Who is affected
Applications and packages relying on the previous behaviour or signature. Code that uses ThemeData, TextSelectionTheme, TextField 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.
Official migration guide (excerpt, © The Flutter Authors, CC BY 3.0)

If you are currently using the following properties of ThemeData, you need to update them to use the new equivalent properties on ThemeData.textSelectionTheme:

Before After
ThemeData.cursorColor TextSelectionThemeData.cursorColor
ThemeData.textSelectionColor TextSelectionThemeData.selectionColor
ThemeData.textSelectionHandleColor TextSelectionThemeData.selectionHandleColor

Code before migration:

ThemeData(
  cursorColor: Colors.red,
  textSelectionColor: Colors.green,
  textSelectionHandleColor: Colors.blue,
)

Code after migration:

ThemeData(
  textSelectionTheme: TextSelectionThemeData(
    cursorColor: Colors.red,
    selectionColor: Colors.green,
    selectionHandleColor: Colors.blue,
  )
)

Default changes

If you weren't using these properties explicitly, but depended on the previous default colors used for text selection you can add a new field to your ThemeData for your app to return to the old defaults as shown:

// Old defaults for a light theme
ThemeData(
  textSelectionTheme: TextSelectionThemeData(
    cursorColor: const Color.fromRGBO(66, 133, 244, 1.0),
    selectionColor: const Color(0xff90caf9),
    selectionHandleColor: const Color(0xff64b5f6),
  )
)
// Old defaults for a dark theme
ThemeData(
  textSelectionTheme: TextSelectionThemeData(
    cursorColor: const Color.fromRGBO(66, 133, 244, 1.0),
    selectionColor: const Color(0xff64ffda),
    selectionHandleColor: const Color(0xff1de9b6),
  )
)

If you are fine with the new defaults, but have failing golden file tests, you can update your master golden files using the following command:

$ flutter test --update-goldens
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?
TextSelectionTheme migration · Boring Doc