Home > Enterprise >  Firebase: How to get only n records at a time instead of whole record firebase real time database?
Firebase: How to get only n records at a time instead of whole record firebase real time database?

Time:08-25

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?

CodePudding user response:

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:

  • Related