title: Flutter - delete directory failed (OS Error: Operation not permitted, errno = 1)
body: <p>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:</p>
  <blockquote>
  <p>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)</p>
  </blockquote>
  <p>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.</p>
  <p>My code for deleting is this:</p>
  <pre><code>CupertinoDialogAction(
      child: Text(&quot;Ok&quot;),
      onPressed: () async {
          Directory dir = await getTemporaryDirectory();
          dir.deleteSync(recursive: true);
          dir.create();
          Navigator.pop(context);
          openFinishDialog();
      }
  ),
  </code></pre>
  <p>Also this error shows only in physical devices and not on simulators.</p>
  <p>I used the dart package path_provider 2.0.8</p>