downloadFile method

Future<File> downloadFile(
  1. String path,
  2. String savePath, {
  3. String? baseUrl,
  4. Options? options,
  5. bool showLoading = false,
  6. CancelToken? cancelToken,
  7. ProgressCallback? onReceiveProgress,
  8. ProgressCallback? onSendProgress,
})

Implementation

Future<File> downloadFile(
  String path,
  String savePath, {
  String? baseUrl,
  Options? options,
  bool showLoading = false,
  CancelToken? cancelToken,
  ProgressCallback? onReceiveProgress,
  ProgressCallback? onSendProgress,
}) async {
  try {
    if (showLoading) DialogUtil.showLoading();

    await _dio.download(
      _buildUrl(path, baseUrl),
      savePath,
      options: options,
      cancelToken: cancelToken,
      onReceiveProgress: onReceiveProgress,
    );

    return File(savePath);
  } on DioException catch (e) {
    throw _handleDioException(e);
  } finally {
    if (showLoading) DialogUtil.hideLoading();
  }
}