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() function is called the dependent widget's build() function is 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.
_setStateAllowed = false;
for (final listener in _beforeList) {
listener.didChangeDependencies();
}
for (final con in _controllerList) {
con.didChangeDependencies();
}
for (final listener in _afterList) {
listener.didChangeDependencies();
}
super.didChangeDependencies();
_setStateAllowed = true;
// The InheritedWidget will dictate if widgets are rebuilt.
_setStateRequested = false;
}