Update for `url_launcher` API change (#1144)

pull/1146/head
Brett Morgan 3 years ago committed by GitHub
parent 2db0b4bf55
commit ed2a422e2a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -165,9 +165,9 @@ class Contents extends StatelessWidget {
onPressed: () async { onPressed: () async {
// Use the url_launcher plugin to open the Flutter docs in // Use the url_launcher plugin to open the Flutter docs in
// a browser. // a browser.
const url = 'https://flutter.dev/docs'; final url = Uri.parse('https://flutter.dev/docs');
if (await launcher.canLaunch(url)) { if (await launcher.canLaunchUrl(url)) {
launcher.launch(url); launcher.launchUrl(url);
} }
}, },
child: const Text('Open Flutter Docs'), child: const Text('Open Flutter Docs'),

@ -95,9 +95,9 @@ class _MyHomePageState extends State<MyHomePage> {
onPressed: () async { onPressed: () async {
// Use the url_launcher plugin to open the Flutter docs in // Use the url_launcher plugin to open the Flutter docs in
// a browser. // a browser.
const url = 'https://flutter.dev/docs'; final url = Uri.parse('https://flutter.dev/docs');
if (await launcher.canLaunch(url)) { if (await launcher.canLaunchUrl(url)) {
launcher.launch(url); launcher.launchUrl(url);
} }
}, },
child: const Text('Open Flutter Docs'), child: const Text('Open Flutter Docs'),

@ -164,9 +164,9 @@ class Contents extends StatelessWidget {
onPressed: () async { onPressed: () async {
// Use the url_launcher plugin to open the Flutter docs in // Use the url_launcher plugin to open the Flutter docs in
// a browser. // a browser.
const url = 'https://flutter.dev/docs'; final url = Uri.parse('https://flutter.dev/docs');
if (await launcher.canLaunch(url)) { if (await launcher.canLaunchUrl(url)) {
launcher.launch(url); launcher.launchUrl(url);
} }
}, },
child: const Text('Open Flutter Docs'), child: const Text('Open Flutter Docs'),

@ -29,9 +29,10 @@ class PolicyDialog extends StatelessWidget {
fontWeight: FontWeight.bold, color: Colors.blue.normal), fontWeight: FontWeight.bold, color: Colors.blue.normal),
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () async { ..onTap = () async {
const url = 'https://policies.google.com/terms'; final url =
if (await url_launcher.canLaunch(url)) { Uri.parse('https://policies.google.com/terms');
await url_launcher.launch(url); if (await url_launcher.canLaunchUrl(url)) {
await url_launcher.launchUrl(url);
} }
}, },
) )
@ -50,9 +51,9 @@ class PolicyDialog extends StatelessWidget {
fontWeight: FontWeight.bold, color: Colors.blue.normal), fontWeight: FontWeight.bold, color: Colors.blue.normal),
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () async { ..onTap = () async {
const url = 'https://unsplash.com/terms'; final url = Uri.parse('https://unsplash.com/terms');
if (await url_launcher.canLaunch(url)) { if (await url_launcher.canLaunchUrl(url)) {
await url_launcher.launch(url); await url_launcher.launchUrl(url);
} }
}, },
) )

@ -8,10 +8,10 @@ import 'package:url_launcher/url_launcher.dart';
import '../../unsplash_access_key.dart'; import '../../unsplash_access_key.dart';
final _unsplashHomepage = final _unsplashHomepage = Uri.parse(
'https://unsplash.com/?utm_source=${Uri.encodeFull(unsplashAppName)}&utm_medium=referral'; 'https://unsplash.com/?utm_source=${Uri.encodeFull(unsplashAppName)}&utm_medium=referral');
final _unsplashPrivacyPolicy = final _unsplashPrivacyPolicy = Uri.parse(
'https://unsplash.com/privacy?utm_source=${Uri.encodeFull(unsplashAppName)}&utm_medium=referral'; 'https://unsplash.com/privacy?utm_source=${Uri.encodeFull(unsplashAppName)}&utm_medium=referral');
class UnsplashNotice extends StatefulWidget { class UnsplashNotice extends StatefulWidget {
const UnsplashNotice({Key? key, required this.child}) : super(key: key); const UnsplashNotice({Key? key, required this.child}) : super(key: key);
@ -64,7 +64,7 @@ class _UnsplashDialog extends StatelessWidget {
text: 'Unsplash', text: 'Unsplash',
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () async { ..onTap = () async {
if (!await launch(_unsplashHomepage)) { if (!await launchUrl(_unsplashHomepage)) {
throw 'Could not launch $_unsplashHomepage'; throw 'Could not launch $_unsplashHomepage';
} }
}, },
@ -81,7 +81,7 @@ class _UnsplashDialog extends StatelessWidget {
text: 'how Unsplash collects and uses data', text: 'how Unsplash collects and uses data',
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () async { ..onTap = () async {
if (!await launch(_unsplashPrivacyPolicy)) { if (!await launchUrl(_unsplashPrivacyPolicy)) {
throw 'Could not launch $_unsplashPrivacyPolicy'; throw 'Could not launch $_unsplashPrivacyPolicy';
} }
}, },

@ -29,9 +29,10 @@ class PolicyDialog extends StatelessWidget {
fontWeight: FontWeight.bold, color: Colors.lightBlue), fontWeight: FontWeight.bold, color: Colors.lightBlue),
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () async { ..onTap = () async {
const url = 'https://policies.google.com/terms'; final url =
if (await url_launcher.canLaunch(url)) { Uri.parse('https://policies.google.com/terms');
await url_launcher.launch(url); if (await url_launcher.canLaunchUrl(url)) {
await url_launcher.launchUrl(url);
} }
}, },
) )
@ -50,9 +51,9 @@ class PolicyDialog extends StatelessWidget {
fontWeight: FontWeight.bold, color: Colors.lightBlue), fontWeight: FontWeight.bold, color: Colors.lightBlue),
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () async { ..onTap = () async {
const url = 'https://unsplash.com/terms'; final url = Uri.parse('https://unsplash.com/terms');
if (await url_launcher.canLaunch(url)) { if (await url_launcher.canLaunchUrl(url)) {
await url_launcher.launch(url); await url_launcher.launchUrl(url);
} }
}, },
) )

@ -8,10 +8,10 @@ import 'package:url_launcher/url_launcher.dart';
import '../../unsplash_access_key.dart'; import '../../unsplash_access_key.dart';
final _unsplashHomepage = final _unsplashHomepage = Uri.parse(
'https://unsplash.com/?utm_source=${Uri.encodeFull(unsplashAppName)}&utm_medium=referral'; 'https://unsplash.com/?utm_source=${Uri.encodeFull(unsplashAppName)}&utm_medium=referral');
final _unsplashPrivacyPolicy = final _unsplashPrivacyPolicy = Uri.parse(
'https://unsplash.com/privacy?utm_source=${Uri.encodeFull(unsplashAppName)}&utm_medium=referral'; 'https://unsplash.com/privacy?utm_source=${Uri.encodeFull(unsplashAppName)}&utm_medium=referral');
class UnsplashNotice extends StatefulWidget { class UnsplashNotice extends StatefulWidget {
const UnsplashNotice({Key? key, required this.child}) : super(key: key); const UnsplashNotice({Key? key, required this.child}) : super(key: key);
@ -65,7 +65,7 @@ class _UnsplashDialog extends StatelessWidget {
text: 'Unsplash', text: 'Unsplash',
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () async { ..onTap = () async {
if (!await launch(_unsplashHomepage)) { if (!await launchUrl(_unsplashHomepage)) {
throw 'Could not launch $_unsplashHomepage'; throw 'Could not launch $_unsplashHomepage';
} }
}, },
@ -82,7 +82,7 @@ class _UnsplashDialog extends StatelessWidget {
text: 'how Unsplash collects and uses data', text: 'how Unsplash collects and uses data',
recognizer: TapGestureRecognizer() recognizer: TapGestureRecognizer()
..onTap = () async { ..onTap = () async {
if (!await launch(_unsplashPrivacyPolicy)) { if (!await launchUrl(_unsplashPrivacyPolicy)) {
throw 'Could not launch $_unsplashPrivacyPolicy'; throw 'Could not launch $_unsplashPrivacyPolicy';
} }
}, },

Loading…
Cancel
Save