onResponse method
Called when the response is about to be resolved.
Implementation
@override
void onResponse(Response response, ResponseInterceptorHandler handler) async {
if (response.statusCode == 200) {
dynamic data = response.data;
if (data is String) {
handler.next(response);
} else {
Map dict = data;
int code = 0;
if (dict.containsKey('code')) {
code = dict['code'];
}
String message = '';
if (dict.containsKey('message') == true) {
message = dict['message'];
}
handler.next(response);
}
} else {
handler.reject(
DioException(
requestOptions: response.requestOptions,
response: response,
type: DioExceptionType.badResponse,
error: "data error",
),
true);
}
}