next method

Future next()

Implementation

Future next() async {
  if (_isEnded || _isLoading) return;
  _isLoading = true;
  return postFrameFuture(() async {
    try {
      final list = await dataSource(
        query,
        PageableRequest(page: _currentPage, size: pageSize),
      );
      if (_currentPage == defaultFirstPage) {
        clear();
      }
      addAllIf(true, list.toList());
      _currentPage += 1;
      _isEnded = pageSize > list.length;
    } finally {
      _isLoading = false;
    }
  });
}