download method
Future<BasicModel>
download(
- String path,
- String savePath, {
- bool? loading,
- dynamic tag,
- dynamic options,
- dynamic onReceiveProgress,
- dynamic cancelToken,
- Object? data,
- bool dataToJson = true,
- Map<
String, dynamic> ? params, - bool deleteOnError = true,
- String lengthHeader = Headers.contentLengthHeader,
- Duration receiveTimeout = const Duration(seconds: 40),
- Duration sendTimeout = const Duration(seconds: 40),
文件下载 File download
Implementation
Future<BasicModel> download(String path, String savePath,
{bool? loading,
dynamic tag,
Options? options,
ProgressCallback? onReceiveProgress,
CancelToken? cancelToken,
Object? data,
bool dataToJson = true,
Map<String, dynamic>? params,
bool deleteOnError = true,
String lengthHeader = Headers.contentLengthHeader,
Duration receiveTimeout = const Duration(seconds: 40),
Duration sendTimeout = const Duration(seconds: 40)}) async {
assert(_singleton != null, '请先调用 initialize');
if (hasNetWork) return notNetWorkModel;
_addLoading(loading);
data = basicDioOptions.extraData?.call(path, data) ?? data;
final res = await dio.download(path, savePath,
onReceiveProgress: onReceiveProgress,
options: _initBasicOptions(options, path)
.copyWith(receiveTimeout: receiveTimeout, sendTimeout: sendTimeout),
data: dataToJson ? jsonEncode(data) : data,
deleteOnError: deleteOnError,
lengthHeader: lengthHeader,
cancelToken: cancelToken);
return _response(res, tag);
}