endBefore method
Creates and returns a new Query that ends before the provided fields relative to the order of the query. The order of the field values must match the order of the order by clauses of the query.
fieldValues the field values to end this query before, in order of the query's order by.
Returns the created Query. Throws an ArgumentError in the cases described in startAt. A later call of an end
cursor (endAt, endBefore or their Document variants) replaces the earlier one.
// Cities whose name sorts before "M".
final QuerySnapshot<Map<String, Object?>> snapshot = await firestore
.collection('cities')
.orderBy('name')
.endBefore(['M'])
.get();
Implementation
Query<T> endBefore(Iterable<Object?> fieldValues) {
final Bound bound = _builder.boundFromFields(
query,
'endBefore',
fieldValues.toList(),
inclusive: false,
);
return _withQuery(query.endAt(bound));
}