onResponse method
Handles chopper response and adds data to existing alice http call
Implementation
@override
// ignore: strict_raw_type
FutureOr<chopper.Response> onResponse(chopper.Response response) {
final httpResponse = AliceHttpResponse()..status = response.statusCode;
if (response.body == null) {
httpResponse
..body = ''
..size = 0;
} else {
httpResponse
..body = response.body
..size = utf8.encode(response.body.toString()).length;
}
httpResponse.time = DateTime.now();
final headers = <String, String>{};
response.headers.forEach((header, values) {
headers[header] = values;
});
httpResponse.headers = headers;
aliceCore.addResponse(
httpResponse,
getRequestHashCode(response.base.request!),
);
return response;
}