Use case
In a few places in docs for BuildContext the following can be found (formatting/newlines mine) (e.g. https://api.flutter.dev/flutter/widgets/BuildContext/dependOnInheritedWidgetOfExactType.html):
This method should not be called from widget constructors or from State.initState methods, because those
methods would not get called again if the inherited value were to change. To ensure that the widget correctly
updates itself when the inherited value changes, only call this (directly or indirectly) from build methods,
layout and paint callbacks, or from State.didChangeDependencies.
Would it make sense to mention why exactly initState is excluded? Does this mean that such methods somehow save which method they were called from, and call them back when necessary? Why doesn't Flutter just call the build method of whatever Widget's context the method was called on, why would it try to call the method that the dependOnInheritedWidgetOfExactType (or others with the same caveat) method call was made from?
Use case
In a few places in docs for
BuildContextthe following can be found (formatting/newlines mine) (e.g. https://api.flutter.dev/flutter/widgets/BuildContext/dependOnInheritedWidgetOfExactType.html):Would it make sense to mention why exactly
initStateis excluded? Does this mean that such methods somehow save which method they were called from, and call them back when necessary? Why doesn't Flutter just call thebuildmethod of whatever Widget's context the method was called on, why would it try to call the method that thedependOnInheritedWidgetOfExactType(or others with the same caveat) method call was made from?