downloadFile static method
Implementation
static Future<dynamic> downloadFile({required String url,String downloadPath = "",Map<String,dynamic >data=const {},Function(Map<String,dynamic >params)? downloadProgress}) async {
dynamic result;
try {
var dio = new Dio();
Response response = await dio.download(url, downloadPath, onReceiveProgress: (count, total) {
if (downloadProgress != null) {
downloadProgress({"count":count,"total":total,"percentage":(count*100/total)});
}
});
if (response.statusCode != 200) {
_handleError(url: url,response: response);
}
else{
result = response.data;
}
}
on Exception catch(e,stack){
_handleException(url:url,exception: e,stackTrace: stack);
}
return result;
}