onResponse method
The callback will be executed on success.
If you want to continue the response, call handler.next
.
If you want to complete the response with some custom data directly,
you can resolve a Response
object with handler.resolve
and other
response interceptor(s) will not be executed.
If you want to complete the response with an error message,
you can reject a DioError
object with handler.reject
.
Implementation
@override
void onResponse(
Response<dynamic> response, ResponseInterceptorHandler handler) {
final GleapNetworkLog gleapNetworkLog = GleapNetworkLog(
type: () {
try {
return response.requestOptions.method.toUpperCase();
} catch (_) {
return null;
}
}(),
url: () {
try {
return response.realUri.toString();
} catch (_) {
return null;
}
}(),
date: DateTime.now(),
request: GleapNetworkRequest(
headers: () {
try {
return _prepareMap(map: response.requestOptions.headers);
} catch (_) {
return null;
}
}(),
payload: () {
try {
return response.requestOptions.data;
} catch (_) {
return '';
}
}(),
),
response: GleapNetworkResponse(
status: () {
try {
return response.statusCode;
} catch (_) {
return null;
}
}(),
statusText: () {
try {
return response.statusMessage;
} catch (_) {
return null;
}
}(),
responseText: () {
try {
return NetworkResponseTypeHelper.getType(data: response.data);
} catch (_) {
return null;
}
}(),
),
success: true,
);
_updateNetworkLogs(gleapNetworkLog);
handler.next(response);
}