request method
Future<Response?>
request(
- String path, {
- Map<
String, dynamic> ? params, - dynamic data,
- CancelToken? cancelToken,
- Options? options,
- ProgressCallback? onSendProgress,
- ProgressCallback? onReceiveProgress,
基础请求
Implementation
Future<Response?> request(
String path, {
Map<String, dynamic>? params,
data,
CancelToken? cancelToken,
Options? options,
ProgressCallback? onSendProgress,
ProgressCallback? onReceiveProgress,
}) async {
options ??= Options(method: 'get');
try {
Response response = await _dio.request(path,
data: data,
queryParameters: params,
cancelToken: cancelToken ?? _cancelToken,
options: options,
onSendProgress: onSendProgress,
onReceiveProgress: onReceiveProgress);
return response;
} on DioException catch (e) {
bool isShowError = true;
if (e.requestOptions.headers.containsKey(showError)) {
isShowError = e.requestOptions.headers[showError];
}
if (isShowError) {
Loading.error(e.message);
}
return null;
}
}