downloadFile static method

Future downloadFile(
  1. String urlPath,
  2. String savePath, {
  3. ProgressCallback? onReceiveProgress,
  4. Map<String, dynamic>? queryParameters,
  5. CancelToken? cancelToken,
  6. bool deleteOnError = true,
  7. String lengthHeader = Headers.contentLengthHeader,
  8. dynamic data,
  9. Options? options,
})

Implementation

static Future downloadFile(String urlPath,
    String savePath, {
      ProgressCallback? onReceiveProgress,
      Map<String, dynamic>? queryParameters,
      CancelToken? cancelToken,
      bool deleteOnError = true,
      String lengthHeader = Headers.contentLengthHeader,
      data,
      Options? options,
    }) async {
  Options requestOptions = options ?? Options();
  Response response;
  try {
    response = await Http().dio.download(urlPath, savePath,
        queryParameters: queryParameters,
        cancelToken: cancelToken ?? _cancelToken,
        data: data,
        options: requestOptions,
        onReceiveProgress: onReceiveProgress ??
                (int count, int total) {
              printWithSystemMethod("$count $total");
            });
    // if (response == null) {
    //   // return AppException(9999, "服务异常");
    //   return AppException(9999, VFTextDelegateHelper.textDelegate.n_server_error);
    // }

    printWithSystemMethod("========能不能拦截住===下载的==method=try=2=========${response}");

    return response;
  } catch (e) {
    printWithSystemMethod("========能不能拦截住===method==4=====拦截器已经转换==$e==");
    if (e is DioException) {
      return e.error;
    }
    return e; //appException
  }
}