download static method

Future<Response?> download(
  1. String url,
  2. String savePath,
  3. ProgressCallback? onReceiveProgress, {
  4. bool newClient = false,
})

下载文件

Implementation

static Future<Response<dynamic>?> download(
  String url,
  String savePath,
  ProgressCallback? onReceiveProgress, {
  bool newClient = false,
}) async {
  try {
    assetDio();
    var client = newClient ? Dio() : _dio!;
    return await client.download(
      url,
      savePath,
      onReceiveProgress: onReceiveProgress,
    );
  } on DioException catch (e) {
    return _convertException(e, url);
  } on SocketException catch (e) {
    return _convertException(e, url);
  }
}