copyDirectory function
Implementation
Future<void> copyDirectory(Directory source, Directory destination) async {
await for (var entity in source.list(recursive: false)) {
if (entity is Directory) {
final newDirectory = Directory(
path.join(destination.absolute.path, path.basename(entity.path)));
await newDirectory.create(recursive: true);
await copyDirectory(entity.absolute, newDirectory);
} else if (entity is File) {
await entity
.copy(path.join(destination.path, path.basename(entity.path)));
}
}
}