ios - 在照片应用 IOS FLUTTER 中下载和显示图像
问题描述
我正在尝试使用 Dio 从 firebase 下载图像,我想将它们存储在 iphone 的内部存储中我应该怎么做(我想在下载后重复使用它们),而且我想在照片应用程序的单独文件夹中显示下载的图像(就像whatsapp媒体将在照片应用程序的whatsapp文件夹中)。
我尝试了以下方法
if(Platform.isAndroid) {
directory = (await getExternalStorageDirectory())!;
}
else{
directory = (await getApplicationDocumentsDirectory());
}
directory = Directory(await getPath(directory, folderName));
if (!await directory.exists()) {
await directory.create(recursive: true);
}
File saveFile = File(directory.path + '/folderName/$fileName');
Fluttertoast.showToast(
msg: 'Downloading Started :-)',
toastLength: Toast.LENGTH_SHORT,
);
await dio.download(url, saveFile.path);
if(Platform.isIOS){
print(await ImageGallerySaver.saveFile(saveFile.path,isReturnPathOfIOS: true));
}
解决方案
推荐阅读
- cpu-usage - Netbeans 8.0.2 CPU 使用率
- windows - 无法从 USB 闪存驱动器启动
- uitableview - UITableViewController 无法使用容器视图正确滚动
- html - 使用 powershell 向 HTML 表中添加行
- algorithm - RB-Trees 的复杂性分析练习
- swift4 - 为什么我们可以在协议扩展中给出变量实例?
- android - 如何预填充 Glide 缓存?
- c++ - 如何有效地将大数存储在整数数组中?C++
- android - 在 onViewCreated 之后运行一个方法
- swift - 是否可以仅显式地遵守协议?