downloadUrl static method

Future<void> downloadUrl({
  1. required String url,
  2. String? filename,
})

Downloads a file directly from a URL (web only - uses browser's native download). On native platforms, use downloadFromUrlStream() method instead.

Implementation

static Future<void> downloadUrl({
  required String url,
  String? filename,
}) async {
  if (kIsWeb) {
    // Use web-specific downloader
    await downloadFromUrl(url, filename);
  } else {
    // On native platforms, use the stream-based method
    await downloadFromUrlStream(
      url: url,
      filename: filename ?? 'download.bin',
    );
  }
}