getNextPage method

Future<PaginatedCollection<Insurance, ListInsurance>> getNextPage(
  1. Future<PaginatedCollection<Insurance, ListInsurance>> retrieveNextPageFunction(
    1. ListInsurance? parameters
    ),
  2. List<Insurance>? 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);
}