From 8114cff3171ac00ba8782a57617dfb704691a2b2 Mon Sep 17 00:00:00 2001 From: Rongjian Zhang Date: Sun, 26 Jun 2022 14:23:50 +0800 Subject: [PATCH] build: update url_launcher --- lib/models/auth.dart | 2 +- lib/models/theme.dart | 2 +- lib/screens/gh_user.dart | 12 ++++++------ lib/utils/utils.dart | 2 +- lib/widgets/action_button.dart | 2 +- lib/widgets/html_view.dart | 2 +- lib/widgets/markdown_view.dart | 2 +- pubspec.lock | 18 ++++++++++++++++-- 8 files changed, 28 insertions(+), 14 deletions(-) diff --git a/lib/models/auth.dart b/lib/models/auth.dart index e17ce78..99a834e 100644 --- a/lib/models/auth.dart +++ b/lib/models/auth.dart @@ -742,7 +742,7 @@ class AuthModel with ChangeNotifier { final repoScope = publicOnly ? 'public_repo' : 'repo'; final scope = Uri.encodeComponent( ['user', repoScope, 'read:org', 'notifications'].join(',')); - launchUrl( + launchStringUrl( 'https://github.com/login/oauth/authorize?client_id=$clientId&redirect_uri=gittouch://login&scope=$scope&state=$_oauthState', ); } diff --git a/lib/models/theme.dart b/lib/models/theme.dart index 35f2c0f..02f6908 100644 --- a/lib/models/theme.dart +++ b/lib/models/theme.dart @@ -259,7 +259,7 @@ class ThemeModel with ChangeNotifier { replace: replace, ); } else { - launchUrl(url); + launchStringUrl(url); } } diff --git a/lib/screens/gh_user.dart b/lib/screens/gh_user.dart index d57c516..ebc1f8e 100644 --- a/lib/screens/gh_user.dart +++ b/lib/screens/gh_user.dart @@ -149,7 +149,7 @@ class _User extends StatelessWidget { leftIconData: Octicons.location, text: Text(p!.location!), onTap: () { - launchUrl('https://www.google.com/maps/place/' + + launchStringUrl('https://www.google.com/maps/place/' + p!.location!.replaceAll(RegExp(r'\s+'), '')); }, ), @@ -158,7 +158,7 @@ class _User extends StatelessWidget { leftIconData: Octicons.mail, text: Text(p!.email), onTap: () { - launchUrl('mailto:' + p!.email); + launchStringUrl('mailto:' + p!.email); }, ), if (isNotNullOrEmpty(p!.websiteUrl)) @@ -170,7 +170,7 @@ class _User extends StatelessWidget { if (!url.startsWith('http')) { url = 'http://$url'; } - launchUrl(url); + launchStringUrl(url); }, ), ], @@ -227,7 +227,7 @@ class _Org extends StatelessWidget { leftIconData: Octicons.location, text: Text(p!.location!), onTap: () { - launchUrl('https://www.google.com/maps/place/' + + launchStringUrl('https://www.google.com/maps/place/' + p!.location!.replaceAll(RegExp(r'\s+'), '')); }, ), @@ -236,7 +236,7 @@ class _Org extends StatelessWidget { leftIconData: Octicons.mail, text: Text(p!.email!), onTap: () { - launchUrl('mailto:' + p!.email!); + launchStringUrl('mailto:' + p!.email!); }, ), if (isNotNullOrEmpty(p!.websiteUrl)) @@ -248,7 +248,7 @@ class _Org extends StatelessWidget { if (!url.startsWith('http')) { url = 'http://$url'; } - launchUrl(url); + launchStringUrl(url); }, ), ], diff --git a/lib/utils/utils.dart b/lib/utils/utils.dart index 9b2c326..3d65e48 100644 --- a/lib/utils/utils.dart +++ b/lib/utils/utils.dart @@ -167,7 +167,7 @@ class PrimerBranchName extends StatelessWidget { } } -launchUrl(String? url) async { +launchStringUrl(String? url) async { if (url == null) return; if (await canLaunch(url)) { diff --git a/lib/widgets/action_button.dart b/lib/widgets/action_button.dart index 9557c0e..ac61859 100644 --- a/lib/widgets/action_button.dart +++ b/lib/widgets/action_button.dart @@ -33,7 +33,7 @@ class ActionItem { text: 'Open in Browser', iconData: Octicons.globe, onTap: (_) { - launchUrl(url); + launchStringUrl(url); }, ), ]; diff --git a/lib/widgets/html_view.dart b/lib/widgets/html_view.dart index 42bb0bf..b033730 100644 --- a/lib/widgets/html_view.dart +++ b/lib/widgets/html_view.dart @@ -67,7 +67,7 @@ class _HtmlViewState extends State { }, navigationDelegate: (request) { if (loaded) { - launchUrl(request.url); // TODO: + launchStringUrl(request.url); // TODO: return NavigationDecision.prevent; } else { loaded = true; diff --git a/lib/widgets/markdown_view.dart b/lib/widgets/markdown_view.dart index 655aea4..fac4015 100644 --- a/lib/widgets/markdown_view.dart +++ b/lib/widgets/markdown_view.dart @@ -155,7 +155,7 @@ class MarkdownFlutterView extends StatelessWidget { } } - launchUrl(url); + launchStringUrl(url); }, styleSheet: MarkdownStyleSheet( a: _basicStyle.copyWith(color: theme.palette.primary), diff --git a/pubspec.lock b/pubspec.lock index 4220311..c9e88a3 100644 --- a/pubspec.lock +++ b/pubspec.lock @@ -970,7 +970,21 @@ packages: name: url_launcher url: "https://pub.dartlang.org" source: hosted - version: "6.0.9" + version: "6.1.3" + url_launcher_android: + dependency: transitive + description: + name: url_launcher_android + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.17" + url_launcher_ios: + dependency: transitive + description: + name: url_launcher_ios + url: "https://pub.dartlang.org" + source: hosted + version: "6.0.17" url_launcher_linux: dependency: transitive description: @@ -1071,4 +1085,4 @@ packages: version: "3.1.0" sdks: dart: ">=2.17.5 <3.0.0" - flutter: ">=2.0.0" + flutter: ">=2.8.0"