downloadFile method
Future<File>
downloadFile(
- String path,
- String savePath, {
- String? baseUrl,
- Options? options,
- bool showLoading = false,
- CancelToken? cancelToken,
- ProgressCallback? onReceiveProgress,
})
Implementation
Future<File> downloadFile(
String path,
String savePath, {
String? baseUrl,
Options? options,
bool showLoading = false,
CancelToken? cancelToken,
ProgressCallback? onReceiveProgress,
}) async {
_activeRequests++;
try {
if (showLoading) ComToast.loading();
final requestOptions = (options ?? Options()).copyWith(
headers: _mergeHeaders(config.getCommonHeaders, options?.headers),
);
await _dio.download(
_buildUrl(path, baseUrl),
savePath,
options: requestOptions,
cancelToken: cancelToken,
onReceiveProgress: onReceiveProgress,
);
return File(savePath);
} finally {
_finishRequest();
if (showLoading) ComToast.hideLoading();
}
}