Does Flutter dependOnInheritedWidgetOfExactType record which method it was called from?

Viewed 64

I have been playing around with InheritedWidgeta etc. lately, and one thing that I don't understand is this sentence form the documentation of dependOnInheritedWidgetOfExactType (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.'''

Does this mean that this method somehow saves which method it was called from? Why can't Flutter just call the build method of whatever Widget's context this method was called on, why would it try to call the method that the depend... call was made from?

0 Answers
Related