Pagination.fromJson constructor

Pagination.fromJson(
  1. Map<String, dynamic> json
)

Converts a json map to a pagination

Implementation

factory Pagination.fromJson(Map<String, dynamic> json) {
  if (json['runtimeType'] == 'page') {
    return PagePagination(
      currentPage: _readCurrentPage(json, 'currentPage'),
      perPage: _readPerPage(json, 'perPage'),
      total: _readTotalPages(json, 'total'),
    );
  } else {
    return CursorPagination(
      startCursor: _readStartCursor(json, 'startCursor'),
      endCursor: _readEndCursor(json, 'endCursor'),
      hasNextPage: _readNextPage(json, 'hasNextPage'),
    );
  }
}