Skip to content
Boring Doc
BreakingHigh impactOfficial migration guidesince 3.13.0

Added missing dispose() for some disposable objects in Flutter

Framework · Official source

Missing calls to 'dispose()' are added for some disposable objects. For example, ContextMenuController did not dispose OverlayEntry, and EditableTextState did not dispose TextSelectionOverlay.

Who is affected
Applications and packages relying on the previous behaviour or signature.
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−x.dispose();
 
 
After
1+if (xIsCreatedByMe) {
2+ x.dispose();
3+}
Raw before / after
x.dispose();
if (xIsCreatedByMe) {
  x.dispose();
}
Official migration guide (excerpt, © The Flutter Authors, CC BY 3.0)

If you encounter the following error, update your code to call dispose() only in cases when your code created the object.

Once you have called dispose() on a <class name>, it can no longer be used.

Code before migration:

x.dispose();

Code after migration:

if (xIsCreatedByMe) {
  x.dispose();
}

To locate the incorrect disposal, check the call stack of the error. If the call stack points to dispose in your code, this disposal is incorrect and should be fixed.

If the error occurs in Flutter code, dispose() was called incorrectly the first time.

You can locate the incorrect call by temporary calling print(StackTrace.current) in the body of the failed method dispose.

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?