copyFile function
Copy the file at path
into target
.
Returns null if path
does not lead to a File,
else the newly created File gets returned.
Implementation
Future<File?> copyFile(String path, Directory target) async {
// ignore: avoid_slow_async_io
if (!await FileSystemEntity.isFile(path)) return null;
final source = File(path).absolute;
final actualTargetFilepath = target.file(source.name).absolute.path;
return source.copy(actualTargetFilepath);
}