Skip to content
Boring Doc
BreakingHigh impactOfficial migration guidesince 3.22.0landed 3.21.0-11.0.pre

Rename MaterialState to WidgetState

Framework · Official source

`MaterialState`, and its related APIs, have been moved out of the Material library and renamed to `WidgetState`.

Who is affected
Applications and packages relying on the previous behaviour or signature. Code that uses MaterialState, WidgetState, MaterialStatePropertyResolver 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+7−7
Before
1−MaterialState selected = MaterialState.selected;
2  
3−final MaterialStateProperty<Color> backgroundColor;
4  
5−class _MouseCursor extends MaterialStateMouseCursor{
6 const _MouseCursor(this.resolveCallback);
7  
8− final MaterialPropertyResolver<MouseCursor?> resolveCallback;
9  
10 @override
11− MouseCursor resolve(Set<MaterialState> states) => resolveCallback(states) ?? MouseCursor.uncontrolled;
12 }
13  
14−BorderSide side = MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
15− if (states.contains(MaterialState.selected)) {
16 return const BorderSide(color: Colors.red);
17 }
18 return null;
19 });
After
1+WidgetState selected = WidgetState.selected;
2  
3+final WidgetStateProperty<Color> backgroundColor;
4  
5+class _MouseCursor extends WidgetStateMouseCursor{
6 const _MouseCursor(this.resolveCallback);
7  
8+ final WidgetPropertyResolver<MouseCursor?> resolveCallback;
9  
10 @override
11+ MouseCursor resolve(Set<WidgetState> states) => resolveCallback(states) ?? MouseCursor.uncontrolled;
12 }
13  
14+BorderSide side = WidgetStateBorderSide.resolveWith((Set<WidgetState> states) {
15+ if (states.contains(WidgetState.selected)) {
16 return const BorderSide(color: Colors.red);
17 }
18 return null;
19 });
Raw before / after
MaterialState selected = MaterialState.selected;

final MaterialStateProperty<Color> backgroundColor;

class _MouseCursor extends MaterialStateMouseCursor{
  const _MouseCursor(this.resolveCallback);

  final MaterialPropertyResolver<MouseCursor?> resolveCallback;

  @override
  MouseCursor resolve(Set<MaterialState> states) => resolveCallback(states) ?? MouseCursor.uncontrolled;
}

BorderSide side = MaterialStateBorderSide.resolveWith((Set<MaterialState> states) {
  if (states.contains(MaterialState.selected)) {
    return const BorderSide(color: Colors.red);
  }
  return null;
});
WidgetState selected = WidgetState.selected;

final WidgetStateProperty<Color> backgroundColor;

class _MouseCursor extends WidgetStateMouseCursor{
  const _MouseCursor(this.resolveCallback);

  final WidgetPropertyResolver<MouseCursor?> resolveCallback;

  @override
  MouseCursor resolve(Set<WidgetState> states) => resolveCallback(states) ?? MouseCursor.uncontrolled;
}

BorderSide side = WidgetStateBorderSide.resolveWith((Set<WidgetState> states) {
  if (states.contains(WidgetState.selected)) {
    return const BorderSide(color: Colors.red);
  }
  return null;
});
Official migration guide (excerpt, © The Flutter Authors, CC BY 3.0)

A [Flutter fix][] is available to help migrate the MaterialState classes to WidgetState.

To migrate, replace MaterialState with WidgetState.

Code before migration:

MaterialState selected = MaterialState.selected;

final MaterialStateProperty&#x3C;Color> backgroundColor;

class _MouseCursor extends MaterialStateMouseCursor{
  const _MouseCursor(this.resolveCallback);

  final MaterialPropertyResolver&#x3C;MouseCursor?> resolveCallback;

  @override
  MouseCursor resolve(Set&#x3C;MaterialState> states) => resolveCallback(states) ?? MouseCursor.uncontrolled;
}

BorderSide side = MaterialStateBorderSide.resolveWith((Set&#x3C;MaterialState> states) {
  if (states.contains(MaterialState.selected)) {
    return const BorderSide(color: Colors.red);
  }
  return null;
});

Code after migration:

WidgetState selected = WidgetState.selected;

final WidgetStateProperty&#x3C;Color> backgroundColor;

class _MouseCursor extends WidgetStateMouseCursor{
  const _MouseCursor(this.resolveCallback);

  final WidgetPropertyResolver&#x3C;MouseCursor?> resolveCallback;

  @override
  MouseCursor resolve(Set&#x3C;WidgetState> states) => resolveCallback(states) ?? MouseCursor.uncontrolled;
}

BorderSide side = WidgetStateBorderSide.resolveWith((Set&#x3C;WidgetState> states) {
  if (states.contains(WidgetState.selected)) {
    return const BorderSide(color: Colors.red);
  }
  return null;
});
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?