limitToLast method

Query limitToLast(
  1. int limit
)

Creates and returns a new Query that only returns the last matching documents.

You must specify at least one orderBy clause for limitToLast queries, otherwise an exception will be thrown during execution.

Implementation

Query limitToLast(int limit) {
  assert(limit > 0, 'limit must be a positive number greater than 0');
  List<List<dynamic>> orders = List.from(parameters['orderBy']);
  assert(orders.isNotEmpty,
      'limitToLast() queries require specifying at least one orderBy() clause');
  return Query._(firestore, _delegate.limitToLast(limit));
}