【发布时间】:2021-01-02 19:08:21
【问题描述】:
我正在尝试从 api 下载图像,不幸的是它显示错误。更改网址效果很好。我该如何解决这个问题?有没有其他方法可以下载这种类型的图像?
这是我用于下载图像的代码:
_downloadandSaveImage() async {
try {
showdownloading = true;
// Saved with this method.
print(widget.imageUrl);
print(_progress);
//var imageId = await ImageDownloader.downloadImage(widget.imageUrl);
var imageId = await ImageDownloader.downloadImage("http://wallpaper.pkappstudio.info/upload/47418_animal2.jpg",
destination: AndroidDestinationType.directoryDCIM
);
Toast.show("Saved!", context, duration: Toast.LENGTH_SHORT, gravity: Toast.BOTTOM);
if (imageId == null) {
return;
}
} on PlatformException catch (error) {
print(error);
}
}
【问题讨论】: