before method
- K? key,
- C? cursor,
- int count
override
Fetches the Page before the provided key
or cursor
.
Implementation
@override
Future<Page<T, C>> before(K? key, C? cursor, int count) async {
// [_before] can be `null`, when there's no below the page above.
if (_before != null) {
_before = _before! + count;
}
final int edgesBefore = _list.length;
final List<T> edges = await _page();
final bool fulfilled =
fulfilledWhenNone || _hasFirst || edges.length - edgesBefore >= count;
Log.debug(
'before($key, $count) -> $fulfilled(${edges.length}), hasNext: ${!_hasLast}, hasPrevious: ${!_hasFirst}',
'$runtimeType',
);
_ensureLimits();
return Page(
fulfilled ? edges : [],
PageInfo(
hasNext: !_hasLast,
hasPrevious: !_hasFirst,
startCursor: _firstCursor,
endCursor: _lastCursor,
),
);
}