toPaged method

Paged<T> toPaged({
  1. required T itemDecoder(
    1. dynamic json
    ),
  2. String? itemsPath,
  3. String? nextCursorPath,
  4. String? prevCursorPath,
  5. String cursorParam = 'cursor',
})

Build a Paged

Provide:

  • itemDecoder: converts a single item JSON to T
  • itemsPath: where list of items live in the body (defaults to root)
  • nextCursorPath/prevCursorPath: optional paths to cursors in body
  • cursorParam: the name of the query param to use when building cursor URLs

Implementation

Paged<T> toPaged({
  required T Function(dynamic json) itemDecoder,
  String? itemsPath,
  String? nextCursorPath,
  String? prevCursorPath,
  String cursorParam = 'cursor',
}) {
  return makePaged<T>(
    body: data,
    headers: headers,
    requestUrl: extra?['requestUrl'] as String?,
    itemDecoder: itemDecoder,
    itemsPath: itemsPath,
    nextCursorPath: nextCursorPath,
    prevCursorPath: prevCursorPath,
    cursorParam: cursorParam,
  );
}