title: I can't save images on IOS but it works perfectly fine on Android (Flutter)
body: <p>I am trying to fetch images from a website and saving it on the mobile phone. It works fine on Android but as soon as I try it on IOS I am not able to download the images and I am not able to save them.</p>
  <pre><code>════════ Exception caught by image resource service ════════════════════════════════════════════════
  The following FileSystemException was thrown resolving an image codec:
  Cannot open file, path = '/Users/benni/Library/Developer/CoreSimulator/Devices/4F5653A9-221B-4346-B3F0-DECF56309E9A/data/Containers/Data/Application/E8D7F059-5D40-4BED-ACAC-79FF451A4DA7/Documents/carImages/968050475/mainImage.jpg' (OS Error: No such file or directory, errno = 2)
  
  When the exception was thrown, this was the stack: 
  #0      _File.open.&lt;anonymous closure&gt; (dart:io/file_impl.dart:366:9)
  (elided 13 frames from dart:async)
  Path: /Users/benni/Library/Developer/CoreSimulator/Devices/4F5653A9-221B-4346-B3F0-DECF56309E9A/data/Containers/Data/Application/E8D7F059-5D40-4BED-ACAC-79FF451A4DA7/Documents/carImages/968050475/mainImage.jpg
  ════════════════════════════════════════════════════════════════════════════════════════════════════
  </code></pre>
  <p>I am creating the folder with the following code:</p>
  <pre class="lang-dart prettyprint-override"><code>      Future&lt;void&gt; _createDirectory() async {
      final String path = await _localPath;
      documentDirectory = await getApplicationDocumentsDirectory();
      final Directory directory =
          await Directory('$path/carImages').create(recursive: true);
    }
  </code></pre>
  <p>I am fetching the images with the following code:</p>
  <pre class="lang-dart prettyprint-override"><code>    Future&lt;void&gt; downloadImagesForCar(List&lt;dynamic&gt; urlList, String firstPath,
        String urlFirstImage, Car car) async {
      //----------------------IMAGE GET
      try {
        String firstImagePath =
            firstPath + &quot;/mainImage.jpg&quot;; // only for first image
        if (!await File(firstImagePath).exists()) {
          get(urlFirstImage + &quot;/webp/420&quot;)
              .then((response) =&gt; {writeImageFile(response, firstImagePath)});
          //  .catchError(() =&gt; {car.mainImageExists = false});
        }
  
        for (int i = 0; i &lt; urlList.length; i++) {
          String filePathAndName = firstPath + &quot;/$i.jpg&quot;;
  
          if (!await File(filePathAndName).exists()) {
            get(urlList[i].toString() + &quot;/webp/420&quot;).then(
                    (response) =&gt; {writeImageFile(response, filePathAndName)})
                // .catchError(handleImageDownloadError())
                ;
          }
        }
      } catch (e) {
   
      }
    }
  </code></pre>
  <p>I am handling the image with the following code:</p>
  <pre class="lang-dart prettyprint-override"><code>     void writeImageFile(var response, String filePathAndName) {
      File imageFile = new File(filePathAndName);
  
      imageFile.writeAsBytesSync(response.bodyBytes); // &lt;-- 3
      imagePaths.add(filePathAndName);
    }
  </code></pre>