Skip to content
Boring Doc
BreakingHigh impactOfficial migration guidesince 3.7.0

Migrate of to non-nullable return values, and add maybeOf

Framework · Official source

This migration guide describes conversion of code that uses various static `of` functions to retrieve information from a context that used to return nullable values, but now return non-nullable values.

Original behavior

Flutter has a common pattern of allowing lookup of some types of widgets (typically `InheritedWidget`s, but also others) using static member functions that are typically called `of`.

New behavior

The change modified these static `of` APIs to return non-nullable values. If a value is not found, they will also now assert in debug mode, and throw an exception in release mode.

Who is affected
Applications and packages relying on the previous behaviour or signature. Code that uses InheritedWidget, AutofillGroup.of, DefaultTabController.of 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+1−1
Before
1−ScrollController? controller = Scrollable.of(context);
After
1+ScrollController? controller = Scrollable.maybeOf(context);
Raw before / after
ScrollController? controller = Scrollable.of(context);
ScrollController? controller = Scrollable.maybeOf(context);
Migration checklist0/4
Official migration guide (excerpt, © The Flutter Authors, CC BY 3.0)

To modify your code to use the new form of the APIs, first convert all instances of the original static of functions (where its nullability is important) to use the maybeOf form instead.

Code before migration:

ScrollController? controller = Scrollable.of(context);

Code after migration:

ScrollController? controller = Scrollable.maybeOf(context);

Then, for instances where the code calls the of API followed by an exclamation point, just remove the exclamation point: it can no longer return a nullable value.

Code before migration:

ScrollController controller = Scrollable.of(context)!;

Code after migration:

ScrollController controller = Scrollable.of(context);

The following can also be helpful:

  • [unnecessary_non_null_assertion][] (linter message) identifies places where an ! operator should be removed
  • [unnecessary_null_checks][] (analysis option) identifies places where the ? operator isn't needed
  • [unnecessary_null_in_if_null_operators][] identifies places where a ?? operator isn't needed
  • [unnecessary_nullable_for_final_variable_declarations][] (analysis option) finds unnecessary question mark operators on final and const variables
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?