launchURL function

Future<void> launchURL(
  1. String url
)

Launches a URL in an external application.

url is the URL to be launched.

Shows a toast with an error message if the launch fails.

Implementation

Future<void> launchURL(final String url) async {
  try {
    final uri = Uri.parse(url);
    if (!await launchUrl(uri, mode: LaunchMode.externalApplication)) {
      throw Exception('Could not launch $url');
    }
  } catch (e) {
    showErrorToast(e.toString());
  }
}