last method

Future<PaginationState<ReturnType>> last()

Jumps to the last page. This page will always have the last pageSize elements of the underlying query, regardless of whether the total document count is evenly divisible by pageSize.

Implementation

Future<PaginationState<ReturnType>> last() async {
  await _waitForInternalState();
  _internalStateObserver.next(null);
  _firstElement = null;
  _lastElement = null;
  _navigatingToLastPage = true;
  final lastPageSnapshot = _templateSnapshotEmitter
      .clone()
      .limit(_options.pageSize * 3)
      .flipSortOrder()
      .snapshots(subscribe: _options.subscribe)
      .map((s) => s.toList().reversed);
  _snapshotSubject.next(lastPageSnapshot);
  return waitForData();
}