my homepage uses 3 different listview.builder to display data from futures
getFuture() async {
setState(() {
Future1 = FirebaseFirestore.instance.collection("Posts").orderBy(sortBy, descending: descending).limit(20).get();
Future2 = FirebaseFirestore.instance.collection("Posts").orderBy("source", descending: descending).limit(10).get();
Future3 = FirebaseFirestore.instance.collection("Posts").orderBy("date_sort", descending: descending).limit(10).get();
});
}
i also implemented lazyloading for Future1:
getDocumentsNext(String sortBy, bool descending) async {
var lastVisible = collectionState!.docs[collectionState!.docs.length-1];
print('listDocument legnth: ${collectionState!.size} last: $lastVisible');
collection = FirebaseFirestore.instance.collection('Posts').orderBy(sortBy, descending: descending).startAfterDocument(lastVisible).limit(25).get();
fetchDocuments(collection!);
}
fetchDocuments(Future collection){
collection.then((value) {
collectionState = value;
value.docs.forEach((element) {
setState(() {
listDocument.add((element.data()));
});
});
});
}
so only Future1 will add more doc to the list upon scrolling vertically, while Future2 & Future3 will remain unchanged and display 10 items only.
however when i try to scroll the listview.builder, for example 5 times which i got 5 x 25 = 125 of docs loaded ... but my firebase console is showing 1k+ of reads, sometimes can go up to 4k-5k reads if i scroll around 10 times...
how can this possible if the size of my entire dataset is just 3k of docs, and i just loaded less than 500 of doc but getting 1k+ of reads sometimes even more than the size of my dataset ?
==========================================================
EDIT: how to avoid extra reads on firebase console ?