streamPaginate method
To stream results from your collection call streamPaginate Stream<List
Implementation
Stream<List<T?>> streamPaginate(
{int? perPage, Query queryBuilder(Query query)?}) {
Stream<QuerySnapshot> snapshot =
_handlePaginateQuery(perPage: perPage, queryBuilder: queryBuilder)
.snapshots();
return snapshot.map((event) {
if (event.docs.length > 0 &&
event.docs.last is QueryDocumentSnapshot<T>) {
_pagination[this.collectionName] = event.docs.last;
} else {
print("End of documents in collection ${this.collectionName}");
}
return event.docs.map<T?>((doc) {
return _toModel(doc);
}).toList();
});
}