xxxxxxxxxx
final sourceFile = await File('/storage/emulated/0/Myfolder/image.jpg');
final newFilePath = await File('/storage/emulated/0/NewFolder/image.jpg');
moveFile(sourceFile, newFilePath);
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;
}
}