download method
Downloads the response body for path to savePath.
onReceiveProgress reports (received, total) byte counts; total may
be -1 if the server doesn't send Content-Length.
Implementation
Future<Result<void>> download(
String path,
String savePath, {
Map<String, dynamic>? queryParameters,
Options? options,
CancelToken? cancelToken,
void Function(int received, int total)? onReceiveProgress,
}) async {
try {
await _dio.download(
path,
savePath,
queryParameters: queryParameters,
options: options,
cancelToken: cancelToken,
onReceiveProgress: onReceiveProgress,
);
return const Success<void>(null);
} on DioException catch (e, st) {
return Error<void>(mapDioException(e, st));
} catch (e, st) {
return Error<void>(
Failure.unknown(message: e.toString(), cause: e, stackTrace: st),
);
}
}