init method

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

Initializes this PageProvider, loading initial Page, if any.

Implementation

@override
Future<Page<T, C>> init(K? key, int count) async {
  _reset(around: key, count: count);

  final List<T> edges = await _page();

  Log.debug(
    'init($key, $count) -> (${edges.length}), hasNext: ${!_hasLast}, hasPrevious: ${!_hasFirst}',
    '$runtimeType',
  );

  if (edges.isEmpty && key != null) {
    try {
      await onNone?.call(key);
    } catch (e) {
      Log.warning('Failed to `onNone`: $e', '$runtimeType');
    }
  }

  _ensureLimits();

  return Page(
    edges,
    PageInfo(
      hasNext: !_hasLast,
      hasPrevious: !_hasFirst,
      startCursor: _firstCursor,
      endCursor: _lastCursor,
    ),
  );
}