无法将文件保存到文档目录 IOS Flutter

问题描述

我尝试测试文件下载并保存到文档目录。该代码适用于 Android,但在 IOS 上失败。代码如下:

var dir = await getApplicationDocumentsDirectory();
var documentName = "";
documentName = "testname.pdf";
var storePath = "${dir.path}/$documentName";
var errorOccurred = false;
try {
  await dio.download(url,storePath,onReceiveProgress: (rec,total) {
    print("Rec: $rec,Total: $total");
    _setState(() {
      downloading = true;
      progressstring = ((rec / total) * 100).toStringAsFixed(0) + "%";
    });
  });
} catch (e) {
  print(e);
}

错误如下:

异常: PlatformException(file_not_found,File not found: '/../Devices/3D122270-E919-455D-AF3F-F048EC32CBB7/data/Containers/Data/Application/1262A294-59DC-47A5-B5A6-23CAAD Caches/testname.pdf',null,null)

我正在模拟器上测试

解决方法

暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!

如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。

小编邮箱:dio#foxmail.com (将#修改为@)