PaginationResponse<T>.fromDummyJson constructor
PaginationResponse<T>.fromDummyJson ()
Creates a PaginationResponse for DummyJSON-style APIs
This is a convenience factory for APIs that follow the DummyJSON format:
{
"products": [...],
"total": 194,
"skip": 10,
"limit": 10
}
Implementation
factory PaginationResponse.fromDummyJson(
Map<String, dynamic> json,
T Function(Map<String, dynamic>) itemFromJson,
String dataKey,
) {
return PaginationResponse.fromJson(
json,
itemFromJson,
dataExtractor: (json) => json[dataKey] as List<dynamic>,
totalExtractor: (json) => json['total'] as int,
skipExtractor: (json) => json['skip'] as int,
limitExtractor: (json) => json['limit'] as int,
);
}