From 9eaaef1048b07923964734a3ed5a4ce5170ecc6e Mon Sep 17 00:00:00 2001 From: Marcus Hoffmann Date: Sat, 18 Feb 2023 21:42:09 +0100 Subject: [PATCH] utils/url_launcher: force opening http(s) links in external browser The (mobile) platform implementations for url_launcher default to opening any http(s) link inside a webview instead of the platform browser. This seems to be a longer-time problem for iOS (https://gitlab.com/famedly/fluffychat/-/issues/519) but very recently started to affect Android as well. Force url_launcher to always use an external application (the browser, most likely, but possibly other apps might handle those links as well) as opening links from a messaging app in a webview provides terrible UX. (For instance a link might lead to some webpage where you start to fill in some info but then you need to ask someone via the messanger but can't go back without closing the webview and losing all state. Or if you happen to re-launch FluffyChat via the home-screen than it goes back to the home view and the webview state is completely lost as well.) --- lib/utils/url_launcher.dart | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/utils/url_launcher.dart b/lib/utils/url_launcher.dart index df3c040a..2553926d 100644 --- a/lib/utils/url_launcher.dart +++ b/lib/utils/url_launcher.dart @@ -84,7 +84,9 @@ class UrlLauncher { ? 'xn--$hostPartPunycode' : hostPart; }).join('.'); - launchUrlString(uri.replace(host: newHost).toString()); + // Force LaunchMode.externalApplication, otherwise url_launcher will default + // to opening links in a webview on mobile platforms. + launchUrlString(uri.replace(host: newHost).toString(), mode: LaunchMode.externalApplication); } void openMatrixToUrl() async {