around method

  1. @override
Future<Page<T, C>> around(
  1. K? key,
  2. C? cursor,
  3. int count
)
override

Fetches the Page around the provided key or cursor.

If neither key nor cursor is provided, then fetches the first Page.

Implementation

@override
Future<Page<T, C>> around(K? key, C? cursor, int count) async {
  final int half = count ~/ 2;

  final Page<T, C> page = await fetch(
    after: cursor,
    last:
        cursor == null
            ? reversed
                ? count
                : null
            : half,
    before: cursor,
    first:
        cursor == null
            ? reversed
                ? null
                : count
            : half,
  );

  return reversed ? page.reversed() : page;
}