如何解决重新启动设备之前,Dart / Flutter图像不会显示在其应用程序或图库中
我用dart编写的android应用程序存在问题,将iamges写入存储设备时,在重新启动设备之前,它们不会显示在其他文件浏览器应用程序或图库应用程序中。我的代码有问题吗?在我测试过的众多应用中,只有fx文件浏览器可以看到它们。
class ImageWriter{
Future write(BooruItem item) async{
try {
var response = await http.get(item.fileURL);
var path = "";
if (Platform.isAndroid){
path = await ExtStorage.getExternalStorageDirectory() + "/Pictures/LoliSnatcher/";
} else if (Platform.isLinux){
path = Platform.environment['HOME'] + "/Pictures/LoliSnatcher/";
}
await Directory(path).create(recursive:true);
File image = new File(path+item.fileURL.substring(item.fileURL.lastIndexOf("/") + 1));
image.writeAsBytesSync(response.bodyBytes);
}
catch (e){
print("Image not found");
}
return (item.fileURL.substring(item.fileURL.lastIndexOf("/") + 1));
}
}
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。