buildGetNextPageParameters method

  1. @override
ListReports buildGetNextPageParameters(
  1. List<Report>? currentPageItems,
  2. {int? pageSize}
)

Builds the ListParametersType-type parameter set to use to retrieve the next page of a PaginatedCollection. This method should be overridden by subclasses to provide the appropriate parameters for the next page request.

Implementation

@override
ListReports buildGetNextPageParameters(List<Report>? currentPageItems,
    {int? pageSize}) {
  ReportType? reportType = currentPageItems?.first.type;
  ListReports? parameters = _getDefaultListReportsParameters(reportType);
  if (filters != null) {
    parameters = filters;
  }
  if (parameters == null) {
    throw Exception(
        'Cannot retrieve next page of a ReportCollection without a report type');
  }

  parameters.beforeId = currentPageItems?.last.id;

  if (pageSize != null) {
    parameters.pageSize = pageSize;
  }

  return parameters;
}