@@ -673,13 +673,32 @@ void _launchUrl(BuildContext context, String urlString) async {
673673 url = store.account.realmUrl.resolve (urlString);
674674 } on FormatException { // TODO(log)
675675 await showError (context, null );
676+ if (! context.mounted) return ; // TODO(dart): redundant for sake of lint
676677 return ;
677678 }
678679
679680 bool launched = false ;
680681 String ? errorMessage;
681682 try {
682- launched = await ZulipBinding .instance.launchUrl (url);
683+ launched = await ZulipBinding .instance.launchUrl (url,
684+ mode: switch (Theme .of (context).platform) {
685+ // TODO(upstream) The url_launcher default on Android is a weird UX:
686+ // opens a webview in-app, but on a blank black background.
687+ // The status bar is hidden:
688+ // https://github.com/flutter/flutter/issues/120883
689+ // but also there's no app bar, no location bar, no share button;
690+ // no browser chrome at all.
691+ // Probably what we really want is a "Chrome custom tab":
692+ // https://github.com/flutter/flutter/issues/18589
693+ // TODO(upstream) With url_launcher's LaunchMode.externalApplication
694+ // on Android, we still don't get the normal Android UX for
695+ // opening a URL in a browser, where the system gives the user
696+ // a bit of UI to choose which browser to use:
697+ // https://github.com/zulip/zulip-flutter/issues/74#issuecomment-1514040730
698+ TargetPlatform .android => LaunchMode .externalApplication,
699+ _ => LaunchMode .platformDefault,
700+ },
701+ );
683702 } on PlatformException catch (e) {
684703 errorMessage = e.message;
685704 }
0 commit comments