launchUrl static method

Future<void> launchUrl(
  1. String url
)

Launches the specified URL using the default web browser.

Checks if the URL can be launched before attempting to open it. If the URL cannot be launched, the method returns silently without throwing an error.

Parameters:

  • url: The URL to launch (must be a valid URL string)

Throws:

  • May throw platform-specific exceptions if URL launching fails.

Implementation

static Future<void> launchUrl(String url) async {
  if (await canLaunchUrlString(url)) {
    await launchUrlString(url);
  }
}