toPaged method
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,
);
}