I've been playing with the RiverPod 2.0 state management package to understand how to use it for CRUD type operations
What I can't understand is how to use the range of providers to support..
- The asynchronous loading of a data object list prior to displaying it in a list view , i.e. a FutureProvider
- Maintaining the data object list in a provider to support CRUD use cases, i.e. a StateNotifierProvider.
In my Flutter list view I am reading the data from the StateNotifierProvider, not the FutureProvider.
It seems like you need two distinct providers for this one situation. Is that correct?
Currently, I am using a FutureProvider to load the data list, and inside this FutureProvider pushing the data into the StateNotifierProvider. Is that the correct approach?
The new way is to use
AsyncNotifier
to asynchronously read data from a database or server. You can read a good article on the subject in more detail:How to use Notifier and AsyncNotifier
The old way, on the other hand, was to use
StateNotifier
withAsync
state. Something like that:The
FutureProvider
is an asynchronous version of theStateProvider
in the sense that it does not serve as a place to store and handle large logic.