downloadAndOpen method

Future<void> downloadAndOpen(
  1. String url,
  2. String filename
)

Downloads a file from the given URL and opens it with the default application.

The behavior differs by platform:

  • On mobile/desktop: Downloads the file to a temporary directory and opens it
  • On web: Triggers a browser download of the file

Parameters:

  • url: The URL of the file to download
  • filename: The name to use for the downloaded file

Throws:

  • May throw exceptions if the download fails or the file cannot be opened.

Implementation

Future<void> downloadAndOpen(String url, String filename) async {
  await platform.downloadAndOpenFile(url, filename);
}