onResponse method
Called when the response is about to be resolved.
Implementation
@override
Future<void> onResponse(
Response response, ResponseInterceptorHandler handler) async {
var intermediate = response;
for (final interceptor in _interceptors.reversed) {
try {
final dynamic res = await interceptor.onResponse(intermediate);
if (res is Response) {
intermediate = res;
continue;
} else if (res is DioException) {
handler.reject(res, false);
return;
}
} on DioException catch (e) {
handler.reject(e, false);
return;
} catch (e) {
handler.reject(
DioException(requestOptions: response.requestOptions, error: e));
return;
}
}
handler.next(intermediate);
}