copyAndRenameFile static method

Future<void> copyAndRenameFile(
  1. String sourcePath,
  2. String targetPath
)

Implementation

static Future<void> copyAndRenameFile(
  String sourcePath,
  String targetPath,
) async {
  final sourceFile = File(sourcePath);
  final targetFile = File(targetPath);

  if (!await sourceFile.exists()) {
    throw FileNotFoundException(sourcePath);
  }

  await targetFile.parent.create(recursive: true);

  await sourceFile.copy(targetFile.path);
}