From 0cdecee771ac4210a49ebd6cd395ffadf80a77a6 Mon Sep 17 00:00:00 2001 From: Morn Date: Mon, 21 Apr 2025 20:38:52 +0800 Subject: [PATCH] fix: canLaunchUrl doesn't work with Flatpak (#7796) --- .../lib/core/helpers/url_launcher.dart | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/frontend/appflowy_flutter/lib/core/helpers/url_launcher.dart b/frontend/appflowy_flutter/lib/core/helpers/url_launcher.dart index 0502e79604..fd8aa03dfe 100644 --- a/frontend/appflowy_flutter/lib/core/helpers/url_launcher.dart +++ b/frontend/appflowy_flutter/lib/core/helpers/url_launcher.dart @@ -44,10 +44,18 @@ Future afLaunchUri( uri = Uri.parse('https://$url'); } - // try to launch the uri directly - bool result = await launcher.canLaunchUrl(uri); + /// opening an incorrect link will cause a system error dialog to pop up on macOS + /// only use [canLaunchUrl] on macOS + /// and there is an known issue with url_launcher on Linux where it fails to launch + /// see https://github.com/flutter/flutter/issues/88463 + bool result = true; + if (UniversalPlatform.isMacOS) { + result = await launcher.canLaunchUrl(uri); + } + if (result) { try { + // try to launch the uri directly result = await launcher.launchUrl( uri, mode: mode,