genericParsePaginationResponseAsList<DataTypeGeneric extends Jsonable<Object>? > method
Future<EResponse<List<DataTypeGeneric> > >
genericParsePaginationResponseAsList<DataTypeGeneric extends Jsonable<Object>? >(})
inherited
Implementation
Future<EResponse<List<DataTypeGeneric>>>
genericParsePaginationResponseAsList<DataTypeGeneric extends Jsonable?>(
Future futureResponse, {DataTypeGeneric? dataType, required String dataListParam}) async {
EResponse response = await getSaveResponse(futureResponse);
try {
List<DataTypeGeneric>? dataList;
if (dataType != null) {
final body = response.body;
if(body is Map) {
Pagination pagination = Pagination.fromJson(body[Pagination.paginationParam]);
response.base.headers[Pagination.totalCountHeader] = pagination.total?.toString() ?? '0';
dataList = dataType.fromJsonList(body[dataListParam]) as List<DataTypeGeneric>?;
}
Object? errorTypeResult = parseError(response);
return EResponse<List<DataTypeGeneric>>(
response.base,
dataList,
error: errorTypeResult
);
}
} catch (e) {
String message = e.toString();
response = EResponse(
http.Response(
response.body?.toString() ?? '',
Jsonable.jsonParserError,
headers: response.base.headers,
isRedirect: response.base.isRedirect,
persistentConnection: response.base.persistentConnection,
reasonPhrase: response.base.reasonPhrase,
request: response.base.request,
),
response.body,
error: message
);
print(e);
}
return EResponse<List<DataTypeGeneric>>(response.base, null, error: response.error);
}