copyFile static method

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

Implementation

static Future<void> copyFile(String sourcePath, String targetPath) async {
  try {
    final file = File(sourcePath);
    Directory(p.dirname(targetPath)).createSync(recursive: true);
    await file.copy(targetPath);
    print('File copied: $sourcePath -> $targetPath');
  } catch (e) {
    print('Error copying file: $e');
  }
}