limit method

Query<T> limit(
  1. int limit
)

Creates and returns a new Query that's additionally limited to only return up to the specified number of documents. This overrides a previous limitToLast.

limit the maximum number of items to return. Throws an ArgumentError if it is not positive.

Returns the created Query.

final QuerySnapshot<Map<String, Object?>> firstThree = await firestore
    .collection('cities')
    .orderBy('name')
    .limit(3)
    .get();

Implementation

Query<T> limit(int limit) {
  return _withQuery(_builder.limit(query, limit));
}