0

I am developing a Flutter application where I need to get 10 records at a time from Firebase Realtime Database. Then on pressing a button, get the next 10 records. Currently, the code I am using is returning all the records

final snapshot = (await ref.child('user').get());

Is there a way to get the first 10 records and after button press get the next 10 records?

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193
  • 1
    Did you see the Firebase documentation on [filtering and limiting data](https://firebase.google.com/docs/database/flutter/lists-of-data#sorting_and_filtering_data)? You'll also want to look at some of the previous [questions on Firebase Realtime Database pagination](https://stackoverflow.com/search?tab=votes&q=%5bfirebase-realtime-database%5d%20pagination) – Frank van Puffelen Aug 24 '22 at 17:10

1 Answers1

0

Then on pressing a button, get the next 10 records.

What you are looking for is called pagination. The key to solving this problem is to limit the results that are coming from the Realtime Database, and load the next n, on request. Here is a concrete example:

Alex Mamo
  • 130,605
  • 17
  • 163
  • 193