didChangeDependencies method

  1. @override
  2. @protected
  3. @mustCallSuper
void didChangeDependencies()
override

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

@override
@protected
@mustCallSuper
void didChangeDependencies() {
  // Important to 'markNeedsBuild()' first
  super.didChangeDependencies();

  /// No 'setState()' functions are allowed to fully function at this point.
  _setStateAllowed = false;

  for (final con in controllerList) {
    con.didChangeDependencies();
  }

  _setStateAllowed = true;

  // The InheritedWidget will dictate if widgets are rebuilt.
  _setStateRequested = false;
}