downloadFile static method

Future<String?> downloadFile({
  1. required String url,
  2. required String fileName,
  3. required String directory,
  4. void onProgress(
    1. double progress
    )?,
})

Downloads a file from the given URL and saves it to the specified directory.

url: The URL of the file to download. fileName: The name to give the downloaded file. directory: The directory where the file should be saved. onProgress: Optional callback that receives download progress (0-100).

Returns the path to the downloaded file, or null if the download fails.

Implementation

static Future<String?> downloadFile({
  required String url,
  required String fileName,
  required String directory,
  void Function(double progress)? onProgress,
}) async {
  if (kIsWeb) return null; // Web implementation would go here
  return await _instance.downloadFile(
    url: url,
    fileName: fileName,
    directory: directory,
    onProgress: onProgress,
  );
}