I tried to test the file download and saving to the documents directory. The code works on Android, but fails on IOS. Here is the code:
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);
}
The error is the following:
Exception: PlatformException(file_not_found, File not found: '/../Devices/3D122270-E919-455D-AF3F-F048EC32CBB7/data/Containers/Data/Application/1262A294-59DC-47A5-B5A6-24FBAD9D53CA/Library/Caches/testname.pdf', null, null)
I am testing on simulator