downloadFile method
Future<File>
downloadFile(
- String path,
- String savePath, {
- String? baseUrl,
- Options? options,
- bool showLoading = false,
- CancelToken? cancelToken,
- ProgressCallback? onReceiveProgress,
- 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();
}
}