New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Need better docs #23
Comments
Provider's official Selector/context.select works for StateNotifier. |
How exactly |
It uses context.read internally. It just abstracts the BuildContext so that you don't have to care read = context.read; |
The example from documentation is not clear: class Counter extends StateNotifier<int> {
Counter(): super(0)
void increment() {
state++;
read<LocalStorage>().writeInt('count', state);
}
} What is LocalStorage, and when had you created it? |
That would be a typical provider setup: MultiProvider(providers: [
Provider(create: (_) => LocalStorage()),
StateNotifierProvider<Counter, int>(create: (_) => Counter()),
]); |
I have added this information to the readme |
As far as I can see, State Notifier is a great and underestimated package that solves two separate problems:
Setup Store ((that's how I call a business-logic class provided by Provider) to be state-based (as in Redux or BLoC), that allows me to move all the data to states and access the current
state
from UI.Thereby, I can use all the benefits of immutable states (for example, creating an undo/redo with state history), but without complexity of patterns mentioned above.
Locate services.
Say, if I have a custom configured Dio-HttpClient, before I should have made it a singleton in order to access it from Store. Because I do not have a context there.
Now I can use
read
/update
methods to directly get this Dio client instance by its Type.Needs more explanation.
Seems like there's no
Selector
orcontext.select()
for StateNotifier? What if I'm getting the same state with small data changes, and I want to subscribe only to those changes selectively, not the whole state updates?Can I have a mixed Store that both
extends StateNotifier
andwith ChangeNotifier
? So it has one part of its data in states, and another part inside the store? (sorry, if it's a silly question)The text was updated successfully, but these errors were encountered: