download method
Future<Response>
download(
- Response source
)
Implementation
Future<Response> download(Response source) async {
Map<String, dynamic>? data = source.data as Map<String, dynamic>?;
if (data == null) {
return Response(data: null, statusCode: 0, requestOptions: RequestOptions());
}
String url = data["output"]["url"];
var dio = Dio();
List pathList = file.path.split('/');
String name = pathList.last;
pathList.removeLast();
//pathList.add("copy_$name");
pathList.add(name);
String copyPath = pathList.join('/');
print("download => 开始下载压缩好的图片: $copyPath");
var response = await dio.download(url, copyPath);
print("download => 完成下载: ${response.statusCode} data: ${response.data}");
return response;
}