didChangeDependencies method
This method is also called immediately after initState
.
Otherwise called only if this State object's Widget
is a dependency of InheritedWidget.
When a InheritedWidget's build() funciton is called
it's dependencies' build() function are also called but not before
their didChangeDependencies() function. Subclasses rarely use this method.
Implementation
@protected
@override
@mustCallSuper
void didChangeDependencies() {
// Important to 'markNeedsBuild()' first
super.didChangeDependencies();
/// No 'setState()' functions are allowed to fully function at this point.
_rebuildAllowed = false;
for (final listener in _beforeList) {
listener.didChangeDependencies();
}
for (final con in _controllerList) {
con.didChangeDependencies();
}
for (final listener in _afterList) {
listener.didChangeDependencies();
}
super.didChangeDependencies();
_rebuildAllowed = true;
if (_rebuildRequested && !_firstBuild) {
_rebuildRequested = false;
/// Perform a 'rebuild' if requested.
refresh();
}
/// Not the first build now.
_firstBuild = false;
}