@@ -673,13 +673,32 @@ void _launchUrl(BuildContext context, String urlString) async {
673
673
url = store.account.realmUrl.resolve (urlString);
674
674
} on FormatException { // TODO(log)
675
675
await showError (context, null );
676
+ if (! context.mounted) return ; // TODO(dart): redundant for sake of lint
676
677
return ;
677
678
}
678
679
679
680
bool launched = false ;
680
681
String ? errorMessage;
681
682
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
+ );
683
702
} on PlatformException catch (e) {
684
703
errorMessage = e.message;
685
704
}
0 commit comments