From 3d4e7a9f9cecad8385c2b01629c81d7936506011 Mon Sep 17 00:00:00 2001 From: JunsuChoi Date: Thu, 23 Jan 2025 15:27:30 +0900 Subject: [PATCH] [url_launcher] Update url_launcher to 6.3.1 (#803) --- packages/url_launcher/CHANGELOG.md | 8 +++- packages/url_launcher/README.md | 4 +- packages/url_launcher/example/lib/main.dart | 47 ++++++++++++++++--- packages/url_launcher/example/pubspec.yaml | 6 +-- .../url_launcher/lib/url_launcher_tizen.dart | 11 ++++- packages/url_launcher/pubspec.yaml | 8 ++-- 6 files changed, 66 insertions(+), 18 deletions(-) diff --git a/packages/url_launcher/CHANGELOG.md b/packages/url_launcher/CHANGELOG.md index e2c52ca04..10bc143fd 100644 --- a/packages/url_launcher/CHANGELOG.md +++ b/packages/url_launcher/CHANGELOG.md @@ -1,6 +1,10 @@ -## NEXT +## 2.1.3 -* Update minimum Flutter and Dart version to 3.13 and 3.1. +* Update minimum Flutter and Dart version to 3.19 and 3.3. +* Remove `file` scheme from supportedSchemes. +* Update the example app. +* Update url_launcher to 6.3.1. +* Update url_launcher_platform_interface to 2.3.2. ## 2.1.2 diff --git a/packages/url_launcher/README.md b/packages/url_launcher/README.md index 5dde997d4..c3ccec21f 100644 --- a/packages/url_launcher/README.md +++ b/packages/url_launcher/README.md @@ -10,8 +10,8 @@ This package is not an _endorsed_ implementation of `url_launcher`. Therefore, y ```yaml dependencies: - url_launcher: ^6.1.0 - url_launcher_tizen: ^2.1.2 + url_launcher: ^6.3.1 + url_launcher_tizen: ^2.1.3 ``` Then you can import `url_launcher` in your Dart code: diff --git a/packages/url_launcher/example/lib/main.dart b/packages/url_launcher/example/lib/main.dart index f88fcfeb9..e3a353f81 100644 --- a/packages/url_launcher/example/lib/main.dart +++ b/packages/url_launcher/example/lib/main.dart @@ -62,7 +62,29 @@ class _MyHomePageState extends State { } } - Future _launchInWebViewOrVC(Uri url) async { + Future _launchInBrowserView(Uri url) async { + if (!await launchUrl(url, mode: LaunchMode.inAppBrowserView)) { + throw Exception('Could not launch $url'); + } + } + + Future _launchInWebView(Uri url) async { + if (!await launchUrl(url, mode: LaunchMode.inAppWebView)) { + throw Exception('Could not launch $url'); + } + } + + Future _launchInAppWithBrowserOptions(Uri url) async { + if (!await launchUrl( + url, + mode: LaunchMode.inAppBrowserView, + browserConfiguration: const BrowserConfiguration(showTitle: true), + )) { + throw Exception('Could not launch $url'); + } + } + + Future _launchAsInAppWebViewWithCustomHeaders(Uri url) async { if (!await launchUrl( url, mode: LaunchMode.inAppWebView, @@ -93,7 +115,7 @@ class _MyHomePageState extends State { } } - Future _launchUniversalLinkIos(Uri url) async { + Future _launchUniversalLinkIOS(Uri url) async { final bool nativeAppLaunchSucceeded = await launchUrl( url, mode: LaunchMode.externalNonBrowserApplication, @@ -101,7 +123,7 @@ class _MyHomePageState extends State { if (!nativeAppLaunchSucceeded) { await launchUrl( url, - mode: LaunchMode.inAppWebView, + mode: LaunchMode.inAppBrowserView, ); } } @@ -167,10 +189,16 @@ class _MyHomePageState extends State { const Padding(padding: EdgeInsets.all(16.0)), ElevatedButton( onPressed: () => setState(() { - _launched = _launchInWebViewOrVC(toLaunch); + _launched = _launchInBrowserView(toLaunch); }), child: const Text('Launch in app'), ), + ElevatedButton( + onPressed: () => setState(() { + _launched = _launchAsInAppWebViewWithCustomHeaders(toLaunch); + }), + child: const Text('Launch in app (Custom Headers)'), + ), ElevatedButton( onPressed: () => setState(() { _launched = _launchInWebViewWithoutJavaScript(toLaunch); @@ -186,7 +214,7 @@ class _MyHomePageState extends State { const Padding(padding: EdgeInsets.all(16.0)), ElevatedButton( onPressed: () => setState(() { - _launched = _launchUniversalLinkIos(toLaunch); + _launched = _launchUniversalLinkIOS(toLaunch); }), child: const Text( 'Launch a universal link in a native app, fallback to Safari.(Youtube)'), @@ -194,7 +222,7 @@ class _MyHomePageState extends State { const Padding(padding: EdgeInsets.all(16.0)), ElevatedButton( onPressed: () => setState(() { - _launched = _launchInWebViewOrVC(toLaunch); + _launched = _launchInWebView(toLaunch); Timer(const Duration(seconds: 5), () { closeInAppWebView(); }); @@ -202,6 +230,13 @@ class _MyHomePageState extends State { child: const Text('Launch in app + close after 5 seconds'), ), const Padding(padding: EdgeInsets.all(16.0)), + ElevatedButton( + onPressed: () => setState(() { + _launched = _launchInAppWithBrowserOptions(toLaunch); + }), + child: const Text('Launch in app with title displayed'), + ), + const Padding(padding: EdgeInsets.all(16.0)), Link( uri: Uri.parse( 'https://pub.dev/documentation/url_launcher/latest/link/link-library.html'), diff --git a/packages/url_launcher/example/pubspec.yaml b/packages/url_launcher/example/pubspec.yaml index c953bea19..910266518 100644 --- a/packages/url_launcher/example/pubspec.yaml +++ b/packages/url_launcher/example/pubspec.yaml @@ -3,13 +3,13 @@ description: Demonstrates how to use the url_launcher_tizen plugin. publish_to: "none" environment: - sdk: ">=3.1.0 <4.0.0" - flutter: ">=3.13.0" + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" dependencies: flutter: sdk: flutter - url_launcher: ^6.1.0 + url_launcher: ^6.3.1 url_launcher_tizen: path: ../ diff --git a/packages/url_launcher/lib/url_launcher_tizen.dart b/packages/url_launcher/lib/url_launcher_tizen.dart index 3fd1d49c9..1f9090b22 100644 --- a/packages/url_launcher/lib/url_launcher_tizen.dart +++ b/packages/url_launcher/lib/url_launcher_tizen.dart @@ -9,7 +9,6 @@ import 'package:url_launcher_platform_interface/url_launcher_platform_interface. /// The Tizen implementation of [UrlLauncherPlatform]. class UrlLauncherPlugin extends UrlLauncherPlatform { static final Set _supportedSchemes = { - 'file', 'http', 'https', }; @@ -46,4 +45,14 @@ class UrlLauncherPlugin extends UrlLauncherPlatform { ).sendLaunchRequest(); return true; } + + @override + Future closeWebView() { + throw UnimplementedError('closeWebView() is not supported.'); + } + + @override + Future supportsCloseForMode(PreferredLaunchMode mode) { + return Future.value(false); + } } diff --git a/packages/url_launcher/pubspec.yaml b/packages/url_launcher/pubspec.yaml index dd246e432..26dc0e1c9 100644 --- a/packages/url_launcher/pubspec.yaml +++ b/packages/url_launcher/pubspec.yaml @@ -2,11 +2,11 @@ name: url_launcher_tizen description: Tizen implementation of the url_launcher plugin. homepage: https://github.com/flutter-tizen/plugins repository: https://github.com/flutter-tizen/plugins/tree/master/packages/url_launcher -version: 2.1.2 +version: 2.1.3 environment: - sdk: ">=3.1.0 <4.0.0" - flutter: ">=3.13.0" + sdk: ">=3.3.0 <4.0.0" + flutter: ">=3.19.0" flutter: plugin: @@ -18,4 +18,4 @@ dependencies: flutter: sdk: flutter tizen_app_control: ^0.2.2 - url_launcher_platform_interface: ^2.0.5 + url_launcher_platform_interface: ^2.3.2