previous method

Future<PaginatedModels> previous()

This method lets you get the previous page of models. If there is no previous page, it will throw a NoPreviousPageException. If you want to check if there is a previous page before calling this method, use hasPreviousPage.

final paginatedModels = await ReplicateModels().listModels();
if (paginatedModels.hasPreviousPage) {
 final previousPage = await paginatedModels.previous();
print(previousPage.results);
}

Implementation

Future<PaginatedModels> previous() async {
  if (!hasPreviousPage) {
    throw NoPreviousPageException();
  }

  assert(previousApiUrl != null, "No previous page exists for this list");

  return await ReplicateModels().listModelsFromApiLink(previousApiUrl!);
}