check before launch url

This commit is contained in:
Fabian Freund
2025-02-23 17:11:53 +01:00
parent bfd7754eda
commit 42e5da0096
+8 -2
View File
@@ -17,9 +17,15 @@ Future<void> launchUrlFeedback(
Uri url, {
LaunchMode mode = LaunchMode.externalApplication,
}) async {
if (!await launchUrl(url, mode: mode)) {
if (await canLaunchUrl(url)) {
if (!await launchUrl(url, mode: mode)) {
if (context.mounted) {
showErrorMessage(context, 'Could not launch URL ($url)');
}
}
} else {
if (context.mounted) {
showErrorMessage(context, 'Could not launch URL ($url)');
showErrorMessage(context, 'Can not handle "${url.scheme}"');
}
}
}