onResponse method
Called when the response is about to be resolved.
Implementation
@override
void onResponse(response, handler) async {
OnResponseHandler? onResponseHandler = HttpService.to.onResponseHandler;
if (onResponseHandler != null) {
String? msg = await onResponseHandler(response);
if (msg != null) {
handler.reject(
DioException(
type: DioExceptionType.badResponse,
message: msg.isEmpty ? '服务器异常' : msg,
requestOptions: response.requestOptions,
response: response,
error: null,
),
);
return;
}
}
handler.next(response);
}