download method
void
download({
- required String url,
- required dynamic successCall(
- String path
- OnProcessCall? processCall,
- OnResponseCompleteCall? completeCall,
文件下载
url
文件网络地址
fileName
下载至本地文件名
completeCall
请求完成后回调
Implementation
void download({
required String url,
required Function(String path) successCall,
OnProcessCall? processCall,
OnResponseCompleteCall? completeCall,
}) {
bindMethods();
String requestId = Uuid().v4().toString();
if (processCall != null) {
_processMap[requestId] = processCall;
}
if (completeCall != null) {
_requestActMap[requestId] = completeCall;
}
Retrofit retrofit = Retrofit(api: url, method: Method.DOWNLOAD);
this._request(
retrofit: retrofit,
requestId: requestId,
responseCall: _DownloadResponseCall(completeCall, successCall, requestId, _processMap),
enableCache: false,
);
}