FirestoreQueryBuilder<Document> constructor

const FirestoreQueryBuilder<Document>(
  1. {Key? key,
  2. required Query<Document> query,
  3. required FirestoreQueryBuilderSnapshotBuilder<Document> builder,
  4. int pageSize = 10,
  5. Widget? child}

Listens to a query and paginates the result in a way that is compatible with infinite scroll views, such as ListView or GridView.

FirestoreQueryBuilder will subscribe to the query and obtain the first pageSize items (10 by default). Then as the UI needs to render more items, it is possible to call FirestoreQueryBuilderSnapshot.fetchMore to obtain more items.

FirestoreQueryBuilder is independent from how the query will be rendered and as such can be used with any existing widget for rendering list of items.

An example of how to combine FirestoreQueryBuilder with ListView would be:

  query: moviesCollection.orderBy('title'),
  builder: (context, snapshot, _) {
    if (snapshot.isFetching) {
      return const CircularProgressIndicator();
    if (snapshot.hasError) {
      return Text('error ${snapshot.error}');

    return ListView.builder(
      itemBuilder: (context, index) {
        // if we reached the end of the currently obtained items, we try to
        // obtain more items
        if (snapshot.hasMore && index + 1 == {
          // Tell FirestoreQueryBuilder to try to obtain more items.
          // It is safe to call this function from within the build method.

        final movie =[index];
        return Text(movie.title);


const FirestoreQueryBuilder({
  Key? key,
  required this.query,
  required this.builder,
  this.pageSize = 10,
})  : assert(pageSize > 1, 'Cannot have a pageSize lower than 1'),
      super(key: key);