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)
| 1 | − | ScrollController? controller = Scrollable.of(context); |
| 1 | + | ScrollController? controller = Scrollable.maybeOf(context); |
Raw before / after
ScrollController? controller = Scrollable.of(context);
ScrollController? controller = Scrollable.maybeOf(context);
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 onfinalandconstvariables
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
- Add maybeOf for all the cases when of returns nullable
- Add Overlay.maybeOf, make Overlay.of return a non-nullable instance
- 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.