image - Flutter How to move file - Stack Overflow

PHOTO EMBED

Mon Nov 01 2021 15:52:52 GMT+0000 (UTC)

Saved by @awaisab171 #dart

Future<File> moveFile(File sourceFile, String newPath) async {
  try {
    // prefer using rename as it is probably faster
    return await sourceFile.rename(newPath);
  } on FileSystemException catch (e) {
    // if rename fails, copy the source file and then delete it
    final newFile = await sourceFile.copy(newPath);
    await sourceFile.delete();
    return newFile;
  }
}
content_copyCOPY

https://stackoverflow.com/questions/54692763/flutter-how-to-move-file