From 42e5da0096f3c8ba47697a3c8f440524a178ce0c Mon Sep 17 00:00:00 2001 From: Fabian Freund Date: Sun, 23 Feb 2025 17:11:53 +0100 Subject: [PATCH] check before launch url --- app/lib/utils/ui_helper.dart | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/app/lib/utils/ui_helper.dart b/app/lib/utils/ui_helper.dart index 35c6d83f..fe732cea 100644 --- a/app/lib/utils/ui_helper.dart +++ b/app/lib/utils/ui_helper.dart @@ -17,9 +17,15 @@ Future 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}"'); } } }