getNextPage method

Future<PaginatedCollection<Batch, ListBatches>> getNextPage(
  1. Future<PaginatedCollection<Batch, ListBatches>> retrieveNextPageFunction(
    1. ListBatches? parameters
    ),
  2. List<Batch>? currentPageItems,
  3. {int? pageSize}
)
inherited

Retrieves the next page of a PaginatedCollection, using the provided retrieveNextPageFunction to retrieve the next page.

Implementation

Future<PaginatedCollection<ListObjectType, ListParametersType>> getNextPage(
    Future<PaginatedCollection<ListObjectType, ListParametersType>> Function(
            ListParametersType? parameters)
        retrieveNextPageFunction,
    List<ListObjectType>? currentPageItems,
    {int? pageSize}) {
  if (currentPageItems == null || currentPageItems.isEmpty) {
    throw PaginationException(ErrorMessages.noMorePagesToRetrieve);
  }

  if (hasMore == false) {
    throw throw PaginationException(ErrorMessages.noMorePagesToRetrieve);
  }

  ListParametersType? parameters =
      buildGetNextPageParameters(currentPageItems, pageSize: pageSize);

  return retrieveNextPageFunction(parameters);
}