Files
FlutterUnit/lib/app/utils/http_utils/response_interceptor.dart
2021-01-24 08:10:16 +08:00

28 lines
1009 B
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
// import 'package:dio/dio.dart';
// import 'result_bean.dart';
//
// // 拦截返回数据,进行统一处理
// class ResponseInterceptors<T> extends InterceptorsWrapper {
// @override
// onResponse(Response response) async {
// RequestOptions option = response.request;
//
// if (option.contentType != null && option.contentType.contains("text")) {
// return ResultBean<T>(data: response.data, status: true, msg: '');
// }
//
// ///一般只需要处理200的情况300、400、500保留错误信息外层为http协议定义的响应码
// if (response.statusCode == 200 || response.statusCode == 201) {
// ///内层需要根据公司实际返回结构解析一般会有codedatamsg字段
// bool status = response.data["status"];
// String msg = response.data["msg"];
// var result = response.data;
// return ResultBean<T>(
// data: result,
// status: status,
// msg: msg,
// );
// }
// }
// }