IMPORTANT
This is a simple state management library used in packages. I don't want to rely on Provider as a dependency.
The selector is straight out of Provider.
There is no support for this package; please use Provider if you want InheritedWidget as state management.
WithValue
WithValue
is anInheritedWidget
that allows you to provide a value to a subtree of widgets and retrieve that value usingWithValue.of<T>(context)
.- Make sure to override the
==
andhashCode
methods for non-primitive types to ensure proper functionality. - Example usage:
WithValue<int>(
value: 42,
child: MyWidget(),
)
int value = WithValue.of<int>(context);
Usage
WithValueUpdate
is anInheritedNotifier
that allows you to provide and update a value to a subtree of widgets and retrieve that value usingWithValueUpdate.of<T>(context)
.- Make sure to override the
==
andhashCode
methods for non-primitive types to ensure proper functionality. - Example usage:
WithValueUpdate<MyNotifier>(
notifier: myNotifier,
child: MyWidget(),
)
MyNotifier notifier = WithValueUpdate.of<MyNotifier>(context);