launchURL static method
- String url
A function to launch a URL.
It takes a String which is the URL to be launched.
It will try to launch the URL with LaunchMode.externalApplication.
If the launch fails, it will throw an Exception.
If an Exception is thrown, it will show a toast with the error message.
Implementation
static Future<void> launchURL(String url) async {
try {
final uri = Uri.parse(url.trim());
if (!await launchUrl(uri, mode: LaunchMode.externalApplication)) {
throw 'تعذر فتح الرابط: $url';
}
} catch (e) {
debugPrint('Launch URL Error: $e');
}
}