Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions packages/url_launcher/url_launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
## 6.2.1

* Fixes incorrect types in `supportsLaunchMode` and
`supportsCloseForLaunchMode`.

## 6.2.0

_Retracted due to incorrect types in new APIs._

* Adds `supportsLaunchMode` for checking whether the current platform supports a
given launch mode, to allow clients that will only work with specific modes
to avoid fallback to a different mode.
Expand Down
6 changes: 3 additions & 3 deletions packages/url_launcher/url_launcher/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ See [`-[UIApplication canOpenURL:]`](https://developer.apple.com/documentation/u
Add any URL schemes passed to `canLaunchUrl` as `<queries>` entries in your
`AndroidManifest.xml`, otherwise it will return false in most cases starting
on Android 11 (API 30) or higher. Checking for
`supportsLaunchMode(PreferredLaunchMode.inAppBrowserView)` also requires
`supportsLaunchMode(LaunchMode.inAppBrowserView)` also requires
a `<queries>` entry to return anything but false. A `<queries>`
element must be added to your manifest as a child of the root element.

Expand Down Expand Up @@ -222,9 +222,9 @@ On some platforms, web URLs can be launched either in an in-app web view, or
in the default browser. The default behavior depends on the platform (see
[`launchUrl`](https://pub.dev/documentation/url_launcher/latest/url_launcher/launchUrl.html)
for details), but a specific mode can be used on supported platforms by
passing a `PreferredLaunchMode`.
passing a `LaunchMode`.

Platforms that do no support a requested `PreferredLaunchMode` will
Platforms that do no support a requested `LaunchMode` will
automatically fall back to a supported mode (usually `platformDefault`). If
your application needs to avoid that fallback behavior, however, you can check
if the current platform supports a given mode with `supportsLaunchMode` before
Expand Down
14 changes: 9 additions & 5 deletions packages/url_launcher/url_launcher/lib/src/url_launcher_uri.dart
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,11 @@

import 'dart:async';

import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart';
// PreferredLaunchMode is hidden to prevent accidentally using it in APIs at
// this layer. If it is ever needed in this file, it should be imported
// separately with a prefix.
import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart'
hide PreferredLaunchMode;

import '../url_launcher_string.dart';
import 'type_conversion.dart';
Expand Down Expand Up @@ -81,15 +85,15 @@ Future<void> closeInAppWebView() async {
/// Calling [launchUrl] with an unsupported mode will fall back to a supported
/// mode, so calling this method is only necessary for cases where the caller
/// needs to know which mode will be used.
Future<bool> supportsLaunchMode(PreferredLaunchMode mode) {
return UrlLauncherPlatform.instance.supportsMode(mode);
Future<bool> supportsLaunchMode(LaunchMode mode) {
return UrlLauncherPlatform.instance.supportsMode(convertLaunchMode(mode));
}

/// Returns true if [closeInAppWebView] is supported for [mode] in the current
/// platform implementation.
///
/// If this returns false, [closeInAppWebView] will not work when launching
/// URLs with [mode].
Future<bool> supportsCloseForLaunchMode(PreferredLaunchMode mode) {
return UrlLauncherPlatform.instance.supportsMode(mode);
Future<bool> supportsCloseForLaunchMode(LaunchMode mode) {
return UrlLauncherPlatform.instance.supportsMode(convertLaunchMode(mode));
}
2 changes: 1 addition & 1 deletion packages/url_launcher/url_launcher/pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ description: Flutter plugin for launching a URL. Supports
web, phone, SMS, and email schemes.
repository: https://github.com/flutter/packages/tree/main/packages/url_launcher/url_launcher
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22
version: 6.2.0
version: 6.2.1

environment:
sdk: ">=3.1.0 <4.0.0"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -251,15 +251,15 @@ void main() {

group('supportsLaunchMode', () {
test('handles returning true', () async {
const PreferredLaunchMode mode = PreferredLaunchMode.inAppBrowserView;
const LaunchMode mode = LaunchMode.inAppBrowserView;
mock.setResponse(true);

expect(await supportsLaunchMode(mode), true);
expect(mock.launchMode, mode);
});

test('handles returning false', () async {
const PreferredLaunchMode mode = PreferredLaunchMode.inAppBrowserView;
const LaunchMode mode = LaunchMode.inAppBrowserView;
mock.setResponse(false);

expect(await supportsLaunchMode(mode), false);
Expand All @@ -269,15 +269,15 @@ void main() {

group('supportsCloseForLaunchMode', () {
test('handles returning true', () async {
const PreferredLaunchMode mode = PreferredLaunchMode.inAppBrowserView;
const LaunchMode mode = LaunchMode.inAppBrowserView;
mock.setResponse(true);

expect(await supportsCloseForLaunchMode(mode), true);
expect(mock.launchMode, mode);
});

test('handles returning false', () async {
const PreferredLaunchMode mode = PreferredLaunchMode.inAppBrowserView;
const LaunchMode mode = LaunchMode.inAppBrowserView;
mock.setResponse(false);

expect(await supportsCloseForLaunchMode(mode), false);
Expand Down