mirror of
https://github.com/flutter/packages.git
synced 2025-06-19 22:03:33 +08:00
[url_launcher] Add InAppBrowserConfiguration
parameter (#5758)
This is #5166 portion of platform interface changes. Adds `InAppBrowserConfiguration` parameter, as well as `InAppBrowserConfiguration.showTitle` parameter that configures whether to show or not to show webpage title
This commit is contained in:
@ -1,3 +1,7 @@
|
||||
## 2.3.0
|
||||
* Adds `InAppBrowserConfiguration` parameter to `LaunchOptions`, to configure in-app browser views, such as Android Custom Tabs or `SFSafariViewController`.
|
||||
* Adds `showTitle` parameter to `InAppBrowserConfiguration` in order to control web-page title visibility.
|
||||
|
||||
## 2.2.1
|
||||
|
||||
* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.
|
||||
|
@ -50,6 +50,18 @@ class InAppWebViewConfiguration {
|
||||
final Map<String, String> headers;
|
||||
}
|
||||
|
||||
/// Additional configuration options for [PreferredLaunchMode.inAppBrowserView].
|
||||
@immutable
|
||||
class InAppBrowserConfiguration {
|
||||
/// Creates a new InAppBrowserConfiguration with given settings.
|
||||
const InAppBrowserConfiguration({this.showTitle = false});
|
||||
|
||||
/// Whether or not to show the webpage title.
|
||||
///
|
||||
/// May not be supported on all platforms.
|
||||
final bool showTitle;
|
||||
}
|
||||
|
||||
/// Options for [launchUrl].
|
||||
@immutable
|
||||
class LaunchOptions {
|
||||
@ -57,6 +69,7 @@ class LaunchOptions {
|
||||
const LaunchOptions({
|
||||
this.mode = PreferredLaunchMode.platformDefault,
|
||||
this.webViewConfiguration = const InAppWebViewConfiguration(),
|
||||
this.browserConfiguration = const InAppBrowserConfiguration(),
|
||||
this.webOnlyWindowName,
|
||||
});
|
||||
|
||||
@ -66,6 +79,9 @@ class LaunchOptions {
|
||||
/// Configuration for the web view in [PreferredLaunchMode.inAppWebView] mode.
|
||||
final InAppWebViewConfiguration webViewConfiguration;
|
||||
|
||||
/// Configuration for the browser view in [PreferredLaunchMode.inAppBrowserView] mode.
|
||||
final InAppBrowserConfiguration browserConfiguration;
|
||||
|
||||
/// A web-platform-specific option to set the link target.
|
||||
///
|
||||
/// Default behaviour when unset should be to open the url in a new tab.
|
||||
|
@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/url_launcher/
|
||||
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22
|
||||
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
|
||||
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
|
||||
version: 2.2.1
|
||||
version: 2.3.0
|
||||
|
||||
environment:
|
||||
sdk: ">=3.0.0 <4.0.0"
|
||||
|
@ -0,0 +1,16 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart';
|
||||
|
||||
void main() {
|
||||
test('InAppBrowserConfiguration defaults to showTitle false', () {
|
||||
expect(const InAppBrowserConfiguration().showTitle, false);
|
||||
});
|
||||
|
||||
test('InAppBrowserConfiguration showTitle can be set to true', () {
|
||||
expect(const InAppBrowserConfiguration(showTitle: true).showTitle, true);
|
||||
});
|
||||
}
|
@ -0,0 +1,28 @@
|
||||
// Copyright 2013 The Flutter Authors. All rights reserved.
|
||||
// Use of this source code is governed by a BSD-style license that can be
|
||||
// found in the LICENSE file.
|
||||
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart';
|
||||
|
||||
void main() {
|
||||
test('LaunchOptions have default InAppBrowserConfiguration when not passed',
|
||||
() {
|
||||
expect(
|
||||
const LaunchOptions().browserConfiguration,
|
||||
const InAppBrowserConfiguration(),
|
||||
);
|
||||
});
|
||||
|
||||
test('passing non-default InAppBrowserConfiguration to LaunchOptions works',
|
||||
() {
|
||||
const InAppBrowserConfiguration browserConfiguration =
|
||||
InAppBrowserConfiguration(showTitle: true);
|
||||
|
||||
const LaunchOptions launchOptions = LaunchOptions(
|
||||
browserConfiguration: browserConfiguration,
|
||||
);
|
||||
|
||||
expect(launchOptions.browserConfiguration, browserConfiguration);
|
||||
});
|
||||
}
|
Reference in New Issue
Block a user