I have a flutter app that saves pdf files in a temporary directory then the user can press a button to delete these files, in Android everything works fine but in iOS I get this error:
Unhandled Exception: FileSystemException: Deletion failed, path = '/var/mobile/Containers/Data/Application/75048CC8-24E7-4BA3-B748-5603D4F74F60/Library/Caches' (OS Error: Operation not permitted, errno = 1)
The weird thing is also that if you refresh the app you can see that the files have been deleted so actually it works but gives error and blocks the app.
My code for deleting is this:
CupertinoDialogAction(
child: Text("Ok"),
onPressed: () async {
Directory dir = await getTemporaryDirectory();
dir.deleteSync(recursive: true);
dir.create();
Navigator.pop(context);
openFinishDialog();
}
),
Also this error shows only in physical devices and not on simulators.
I used the dart package path_provider 2.0.8