copyFileToDownloads static method

Future<void> copyFileToDownloads(
  1. String sourcePath,
  2. String fileName
)

Implementation

static Future<void> copyFileToDownloads(
  String sourcePath,
  String fileName,
) async {
  final downloadsDir = Directory('/storage/emulated/0/Download');
  if (!await downloadsDir.exists()) {
    throw Exception('Downloads folder not found.');
  }

  final destinationPath = '${downloadsDir.path}/$fileName';
  await copyFile(sourcePath, destinationPath);
}