1

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.

  • Thanks everyone. however i solve this problem with the help of chat GPT. heres the code: [Gist Link] (https://gist.github.com/7ANV1R/ba49ffb6ae131943f48365876c5cf068) – Tanvir Ibn Mizan Jun 14 '23 at 10:45

1 Answers1

1

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:

Ruble
  • 2,589
  • 3
  • 6
  • 29