Skip to content

Commit

Permalink
[url_launcher] Update url_launcher to 6.3.1 (#803)
Browse files Browse the repository at this point in the history
  • Loading branch information
JSUYA authored Jan 23, 2025
1 parent 212c105 commit 3d4e7a9
Show file tree
Hide file tree
Showing 6 changed files with 66 additions and 18 deletions.
8 changes: 6 additions & 2 deletions packages/url_launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -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

Expand Down
4 changes: 2 additions & 2 deletions packages/url_launcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
47 changes: 41 additions & 6 deletions packages/url_launcher/example/lib/main.dart
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,29 @@ class _MyHomePageState extends State<MyHomePage> {
}
}

Future<void> _launchInWebViewOrVC(Uri url) async {
Future<void> _launchInBrowserView(Uri url) async {
if (!await launchUrl(url, mode: LaunchMode.inAppBrowserView)) {
throw Exception('Could not launch $url');
}
}

Future<void> _launchInWebView(Uri url) async {
if (!await launchUrl(url, mode: LaunchMode.inAppWebView)) {
throw Exception('Could not launch $url');
}
}

Future<void> _launchInAppWithBrowserOptions(Uri url) async {
if (!await launchUrl(
url,
mode: LaunchMode.inAppBrowserView,
browserConfiguration: const BrowserConfiguration(showTitle: true),
)) {
throw Exception('Could not launch $url');
}
}

Future<void> _launchAsInAppWebViewWithCustomHeaders(Uri url) async {
if (!await launchUrl(
url,
mode: LaunchMode.inAppWebView,
Expand Down Expand Up @@ -93,15 +115,15 @@ class _MyHomePageState extends State<MyHomePage> {
}
}

Future<void> _launchUniversalLinkIos(Uri url) async {
Future<void> _launchUniversalLinkIOS(Uri url) async {
final bool nativeAppLaunchSucceeded = await launchUrl(
url,
mode: LaunchMode.externalNonBrowserApplication,
);
if (!nativeAppLaunchSucceeded) {
await launchUrl(
url,
mode: LaunchMode.inAppWebView,
mode: LaunchMode.inAppBrowserView,
);
}
}
Expand Down Expand Up @@ -167,10 +189,16 @@ class _MyHomePageState extends State<MyHomePage> {
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);
Expand All @@ -186,22 +214,29 @@ class _MyHomePageState extends State<MyHomePage> {
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)'),
),
const Padding(padding: EdgeInsets.all(16.0)),
ElevatedButton(
onPressed: () => setState(() {
_launched = _launchInWebViewOrVC(toLaunch);
_launched = _launchInWebView(toLaunch);
Timer(const Duration(seconds: 5), () {
closeInAppWebView();
});
}),
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'),
Expand Down
6 changes: 3 additions & 3 deletions packages/url_launcher/example/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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: ../

Expand Down
11 changes: 10 additions & 1 deletion packages/url_launcher/lib/url_launcher_tizen.dart
Original file line number Diff line number Diff line change
Expand Up @@ -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<String> _supportedSchemes = <String>{
'file',
'http',
'https',
};
Expand Down Expand Up @@ -46,4 +45,14 @@ class UrlLauncherPlugin extends UrlLauncherPlatform {
).sendLaunchRequest();
return true;
}

@override
Future<void> closeWebView() {
throw UnimplementedError('closeWebView() is not supported.');
}

@override
Future<bool> supportsCloseForMode(PreferredLaunchMode mode) {
return Future<bool>.value(false);
}
}
8 changes: 4 additions & 4 deletions packages/url_launcher/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand All @@ -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

0 comments on commit 3d4e7a9

Please sign in to comment.