Things that I know about InheritedWidget?
InheritedWidgets are not rebuilts instead we have to create a new InheritedWidget with a new value. Then inside the updateShouldNotify() method will compare its old and current object and return true or false.
if updateShouldNotify() returns true -> then dependent contexts get rebuild.
if updateShouldNotify() returns false -> then dependent contexts doesn't rebuild.
@override
bool updateShouldNotify(_InheritedCount old) {
return old.state != state;
}
So every time when we creating a new instance of the previous InheritedWidget will call that updateShouldNotify() method and decided to rebuilt their dependents or not.
What I want to know about InheritedWidget ? (things that I confused)
- Does every InheritedWidget need to be wrap with StatefulWidget to creates its new instance of that InheritedWidget ?
- Does ChangeNotifierProvider wrap its InheritedWidget (or InheritedProvider) in a StatefulWidget to recreate new InheritedWidget, when ChangeNotifier object sends change notification to its ChangeNotifierProvider() ?
(be kind about how I handle English language)