saveResponse method
Implementation
@override
Future<String> saveResponse(Response response) {
HttpActivity httpActivity = _activities.firstWhere(
(data) => data.request?.requestHashCode == response.requestOptions.hashCode,
orElse: () => HttpActivity(
response: HttpResponse(
createdAt: DateTime.now().millisecondsSinceEpoch,
responseHeader: response.headers.map,
responseBody: _jsonUtil.encodeRawJson(response.data),
responseStatusCode: response.statusCode,
responseStatusMessage: response.statusMessage,
responseSize: _byteUtil.stringToBytes(response.data.toString()),
requestHashCode: response.requestOptions.hashCode,
),
));
final httpResponse = HttpResponse(
createdAt: DateTime.now().millisecondsSinceEpoch,
responseHeader: response.headers.map,
responseBody: _jsonUtil.encodeRawJson(response.data),
responseStatusCode: response.statusCode,
responseStatusMessage: response.statusMessage,
responseSize: _byteUtil.stringToBytes(response.data.toString()),
requestHashCode: response.requestOptions.hashCode,
);
_responses.addAll([httpResponse]);
httpActivity.response = httpResponse;
_dataSubject.add(_activities);
return Future.value('success');
}