Skip to content
Boring Doc
BreakingHigh impactOfficial migration guidesince 1.17.0landed 1.16.3

The forgetChild() method must call super

Framework · Official source

A recent global key duplication detection refactor now requires `Element` subclasses that override the `forgetChild()` to call `super()`.

Original behavior

When encountering a global key duplication that will be cleaned up by an element rebuild later, we must not report global key duplication. Our previous implementation threw an error as soon as duplication was detected, and didn't wait for the rebuild if the element with the duplicated global key would have rebuilt.

New behavior

The `forgetChild` of abstract class `Element` has a base implementation to remove global key reservation, and it is enforced by the `@mustCallSuper` meta tag. All subclasses that override the method have to call `super`; otherwise, the analyzer shows a linting error and global key duplication detection might throw an unexpected error.

Who is affected
Applications and packages relying on the previous behaviour or signature. Code that uses Element.
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.
APIs mentioned:Element

Before and after (from the official guide)

dart+1−0
Before
1 class CustomElement extends Element {
2  
3 @override
4 void forgetChild(Element child) {
5 ...
 
6 }
7 }
After
1 class CustomElement extends Element {
2  
3 @override
4 void forgetChild(Element child) {
5 ...
6+ super.forgetChild(child);
7 }
8 }
Raw before / after
class CustomElement extends Element {

    @override
    void forgetChild(Element child) {
        ...
    }
}
class CustomElement extends Element {

    @override
    void forgetChild(Element child) {
        ...
        super.forgetChild(child);
    }
}
Official migration guide (excerpt, © The Flutter Authors, CC BY 3.0)

In the following example, an app's Element subclass overrides the forgetChild method.

Code before migration:

class CustomElement extends Element {

    @override
    void forgetChild(Element child) {
        ...
    }
}

Code after migration:

class CustomElement extends Element {

    @override
    void forgetChild(Element child) {
        ...
        super.forgetChild(child);
    }
}
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?
The forgetChild() method must call super · Boring Doc