downloadData static method
dynamic
downloadData(})
Implementation
static downloadData(
String url, {
required String savePath,
Function(Map? response)? onSuccess,
Function(String? error)? onError,
}) async {
try {
Response response;
Dio? dio = UnitsForNetwork.dio;
response = await dio!.download(url, savePath);
ResponseBody responseData = response.data;
if (responseData.statusCode == 200) {
if (onSuccess != null) onSuccess(null);
} else {
if (onError != null) onError(null);
}
debugPrint(responseData.toString());
} catch (e) {
debugPrint('请求出错:$e');
if (onError != null) onError(e.toString());
}
}