copyFolder function

Future<void> copyFolder(
  1. String sourcePath,
  2. String destinationPath,
  3. String widgetName
)

Implementation

Future<void> copyFolder(
    String sourcePath, String destinationPath, String widgetName) async {
  Directory sourceDir = Directory(sourcePath);
  Directory destDir = Directory(destinationPath);
  if (!await destDir.exists()) {
    await destDir.create(recursive: true);
  }
  List<FileSystemEntity> contents = sourceDir.listSync();
  for (var entity in contents) {
    if (entity is File) {
      String newPath = path.join(destinationPath, path.basename(entity.path));
      await entity.copy(newPath);
    }
  }
}