didChangeDependencies method
Called when a dependency of this State object changes.
For example, if the previous call to build referenced an InheritedWidget that later changed, the framework would call this method to notify this object about the change.
This method is also called immediately after initState. It is safe to call BuildContext.dependOnInheritedWidgetOfExactType from this method.
Subclasses rarely override this method because the framework always calls build after a dependency changes. Some subclasses do override this method because they need to do some expensive work (e.g., network fetches) when their dependencies change, and that work would be too expensive to do for every build.
Implementation
@override
void didChangeDependencies() {
super.didChangeDependencies();
// The web driver asks matchMedia inside morphTo; a Dart controller has no
// MediaQuery, so the widget pushes the answer down. Same decision, same
// place in the flow. This runs immediately after initState and again on
// every dependency change, so it is always current before a frame paints.
// maybe- so a MorphIcon works outside a MaterialApp/MediaQuery too; with
// no ambient MediaQuery there is no accessibility preference to honour.
_reducedMotion = MediaQuery.maybeDisableAnimationsOf(context) ?? false;
_morph?.reducedMotion = _reducedMotion;
}