title: Flutter - Cannot copy file to new path
body: <p>I want to copy the image to the application directory, but I always get this error:</p>
  
  <blockquote>
    <p>[ERROR:flutter/shell/common/shell.cc(181)] Dart Error: Unhandled
    exception: E/flutter ( 4159): FileSystemException: <strong>Cannot copy file</strong> to
    '/data/user/0/com.vendetta.recipe/app_flutter', path =
    '/storage/emulated/0/Android/data/com.vendetta.recipe/files/Pictures/a6fd32a9-60b2-4cff-8f10-2ffc2933bf751208556873045090039.jpg'
    (OS Error: Is a directory, errno = 21) E/flutter ( 4159): #0<br>
    _File.copy. (dart:io/file_impl.dart:340:9) E/flutter ( 4159): #1      _RootZone.runUnary
    (dart:async/zone.dart:1379:54) E/flutter ( 4159): #2<br>
    _FutureListener.handleValue (dart:async/future_impl.dart:129:18) E/flutter ( 4159): #3<br>
    Future._propagateToListeners.handleValueCallback
    (dart:async/future_impl.dart:642:45) E/flutter ( 4159): #4<br>
    Future._propagateToListeners (dart:async/future_impl.dart:671:32)
    E/flutter ( 4159): #5      Future._completeWithValue
    (dart:async/future_impl.dart:486:5) E/flutter ( 4159): #6<br>
    Future._asyncComplete.
    (dart:async/future_impl.dart:516:7) E/flutter ( 4159): #7<br>
    _microtaskLoop (dart:async/schedule_microtask.dart:41:21) E/flutter ( 4159): #8      _startMicrotaskLoop
    (dart:async/schedule_microtask.dart:50:5)</p>
  </blockquote>
  
  <p>I want to copy this image, to be sure, when I save it, that the user is not deleting an important file. This file I wanted to store inside the database. </p>
  
  <p>This is the code where I copy the image, that was taken with <a href="https://pub.dartlang.org/packages/image_picker" rel="noreferrer">image_picker</a>:</p>
  
  <pre><code>Directory directory = await getApplicationDocumentsDirectory();
  String path = directory.path;
  File newImage = await _image.copy('$path');
  </code></pre>
  
  <p>I hope somebody is able to solve my problem.</p>