download<T> method
Future<Result<T> >
download<T>(
- String urlPath,
- dynamic savePath, {
- dynamic data,
- Map<
String, dynamic> ? queryParameters, - RestApiClientRequestOptions? options,
- ProgressCallback? onReceiveProgress,
- CancelToken? cancelToken,
- bool deleteOnError = true,
- String lengthHeader = Headers.contentLengthHeader,
- FutureOr<
T> onSuccess(- dynamic data
- FutureOr<
T> onError(- dynamic data
override
Implementation
@override
Future<Result<T>> download<T>(
String urlPath,
savePath, {
data,
Map<String, dynamic>? queryParameters,
RestApiClientRequestOptions? options,
ProgressCallback? onReceiveProgress,
CancelToken? cancelToken,
bool deleteOnError = true,
String lengthHeader = Headers.contentLengthHeader,
FutureOr<T> Function(dynamic data)? onSuccess,
FutureOr<T> Function(dynamic data)? onError,
}) async {
try {
final response = await _dio.download(
urlPath,
savePath,
queryParameters: queryParameters,
options: options?.toOptions(),
data: data,
onReceiveProgress: onReceiveProgress,
cancelToken: cancelToken,
deleteOnError: deleteOnError,
lengthHeader: lengthHeader,
);
return NetworkResult(
response: response,
data: await _resolveResult(response.data, onSuccess),
);
} on DioException catch (e) {
await exceptionHandler.handle(e, silent: options?.silentException);
return NetworkResult(
response: e.response,
exception: e,
statusCode: e.response?.statusCode,
statusMessage: e.response?.statusMessage,
);
}
}