performRebuild method
Keeps the subtree as it is when the dependents only have to be notified of a change (notifyDependents).
Two halves, because build cannot be skipped: ComponentElement calls it either way. It hands back the widget of the last real build, and this method leaves the child element alone.
The subtree is rebuilt anyway when:
- autoSelfDependence - the element declared an automatic dependency on itself (used by initializers during the initialization phases).
_forceRebuild- the subtree must be rebuilt because the parent is updating the element or the element depends on itself.
Implementation
@override
void performRebuild() {
// The other way: a `scopeKey` getter that starts returning something else
// -- a new widget with a different key, or a value read from the element's
// own state.
assert(_debugCheckScopeKeyOwnership());
super.performRebuild();
// `super.performRebuild()` invokes the common sync [init] inside
// Flutter's build error boundary. A thrown init is terminal and leaves
// `_didInit` false for good, so the asynchronous phase of a scope that
// never synchronously came to be does not start at all -- and the one
// that did starts it exactly once, on the build that ran the hook.
if (_didInit && !_didStartAsyncInit) {
_didStartAsyncInit = true;
_performAsyncInit(); // ignore: discarded_futures
}
}