首页 > 解决方案 > 在照片应用 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));
}

标签: iosiphoneflutterfirebase-realtime-databasedownload

解决方案


推荐阅读