infinite_scroll_pagination with FutureProvider (Riverpod)
usually i create a FutureProvider which is dependent on search query(StateProvider).
final allAgentSearchQueryProvider = StateProvider<String>((ref) {
return '';
});
final allAgentProvider = FutureProvider<List<AgentPreviewModel>>(
(ref) {
final query = ref.watch(allAgentSearchQueryProvider);
final type = ref.watch(agentTypeQueryProvider);
return ref.watch(agentAPIProvider).getAllAgents(query, type);
},
);
with this i can create easy AsyncValue with my search Query cause everytime i update StateProvider the futureProvider automatically update value.
I want this with infinite_scroll_pagination.
The answer is long enough to easily fit into this post. In a simple case, you can use the riverpod_infinite_scroll package, where pagination is already implemented.
Additional materials for self-implementation: