canOpenUrl function
Check if a URL can be opened.
url - The URL to check.
Returns true if the URL can be launched, false otherwise.
Example:
if (await canOpenUrl('https://example.com')) {
await openUrl('https://example.com');
}
Implementation
Future<bool> canOpenUrl(String url) async {
try {
final uri = Uri.parse(url);
return await canLaunchUrl(uri);
} catch (e) {
NyLogger.error('canOpenUrl: Error checking URL: $e');
return false;
}
}