简体   繁体   中英

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

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?

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:

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM