1
0
mirror of https://github.com/flutter/samples.git synced 2025-11-08 13:58:47 +00:00

Update for url_launcher API change (#1144)

This commit is contained in:
Brett Morgan
2022-04-26 07:17:15 +10:00
committed by GitHub
parent 2db0b4bf55
commit ed2a422e2a
7 changed files with 35 additions and 33 deletions

View File

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

View File

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