request method

Future<Response?> request(
  1. String path, {
  2. Map<String, dynamic>? params,
  3. dynamic data,
  4. CancelToken? cancelToken,
  5. Options? options,
  6. ProgressCallback? onSendProgress,
  7. 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;
  }
}