paginate method

Future<List<T?>> paginate({
  1. int? perPage,
  2. Query<Object?> queryBuilder(
    1. Query<Object?> query
    )?,
})

To get results limit and load more as pagination from your collection call paginate you can build your query like where orderBy or any query buildr methods in queryBuilder you can set perPage in your call or set in your model List

Implementation

Future<List<T?>> paginate(
    {int? perPage, Query queryBuilder(Query query)?}) async {
  QuerySnapshot snapshot =
      await _handlePaginateQuery(perPage: perPage, queryBuilder: queryBuilder)
          .get();
  if (snapshot.docs.length > 0) {
    _pagination[this.collectionName] = snapshot.docs.last;
  } else {
    print("End of documents in collection ${this.collectionName}");
  }
  return snapshot.docs.map<T?>((doc) {
    return _toModel(doc);
  }).toList();
}