-1

I have made this stream that fetch 10 user from firebase. and using streamBuilder it shows user in a Listview(Flutter App). but how to use pagination in such case to get 10 more users after user scroll half of the screen.

this is my stream.which returns a list of UserDetails.

final _refrence = Firestore.instance;


Stream<List<UserDetails>> userStream() {
return _refrence.collection('users').limit(10).snapshots().map((event) =>
event.docs.map((e) => UserDetails.fromJson(e.data())).toList());
}
vijayrealdeal
  • 19
  • 1
  • 1
  • 7

1 Answers1

0

Use a ScrollController to detect how far you've scrolled. Then when your user have reached your given criteria, increase the limit via for example a parameter passed into the userStream method.

You can check the ScrollController code at this previously asked question.

Robert Sandberg
  • 6,832
  • 2
  • 12
  • 30