didChangeDependencies method
Called when a dependency of this element changes.
The dependOnInheritedWidgetOfExactType registers this element as depending on inherited information of the given type. When the information of that type changes at this location in the tree (e.g., because the InheritedElement updated to a new InheritedWidget and InheritedWidget.updateShouldNotify returned true), the framework calls this function to notify this element of the change.
Implementation
@override
void didChangeDependencies() {
super.didChangeDependencies();
final newContainer = ProviderScope.containerOf(this);
if (_container != newContainer) {
_container = newContainer;
for (final dependency in _dependencies.values) {
dependency.close();
}
_dependencies.clear();
}
}