Closed iambudi closed 5 years ago
Hooks are not a state management library, at least not by default.
They allow some pretty powerful stuff in that matter, but flutter_hooks
will hardly suggest one over another. You're free to use redux, bloc, mobx or whatever you like in combination with hooks. Or even bake your own
I thought when i read the example code final counter = useState<int>(5);
that can increment the value and update the UI it holds the local state.
Thanks for the clarification.
That is the case. But this is equal to creating a counter
property on a State
subclass. It's not a global state
You can make one though. In react, there are multiple user made hooks that do something similar. But it's completely outside of the scope of this library.
@rrousselGit any ideas on how to create such hook? I'd imagine something related to context, but unlike react, we can't create a new context and use a provider to assign a custom value and dispatch in a tree. Also inherited widget doesn't sound practical.
See Riverpod, it's similar
What is best practice to use global state without having intermediary sharedPreference?