Skip to content

Commit 7beab0d

Browse files
authored
[url_launcher] Add InAppBrowserConfiguration parameter (flutter#5758)
This is flutter#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
1 parent 31fc7b5 commit 7beab0d

File tree

5 files changed

+65
-1
lines changed

5 files changed

+65
-1
lines changed

packages/url_launcher/url_launcher_platform_interface/CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 2.3.0
2+
* Adds `InAppBrowserConfiguration` parameter to `LaunchOptions`, to configure in-app browser views, such as Android Custom Tabs or `SFSafariViewController`.
3+
* Adds `showTitle` parameter to `InAppBrowserConfiguration` in order to control web-page title visibility.
4+
15
## 2.2.1
26

37
* Updates minimum supported SDK version to Flutter 3.10/Dart 3.0.

packages/url_launcher/url_launcher_platform_interface/lib/src/types.dart

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,13 +50,26 @@ class InAppWebViewConfiguration {
5050
final Map<String, String> headers;
5151
}
5252

53+
/// Additional configuration options for [PreferredLaunchMode.inAppBrowserView].
54+
@immutable
55+
class InAppBrowserConfiguration {
56+
/// Creates a new InAppBrowserConfiguration with given settings.
57+
const InAppBrowserConfiguration({this.showTitle = false});
58+
59+
/// Whether or not to show the webpage title.
60+
///
61+
/// May not be supported on all platforms.
62+
final bool showTitle;
63+
}
64+
5365
/// Options for [launchUrl].
5466
@immutable
5567
class LaunchOptions {
5668
/// Creates a new parameter object with the given options.
5769
const LaunchOptions({
5870
this.mode = PreferredLaunchMode.platformDefault,
5971
this.webViewConfiguration = const InAppWebViewConfiguration(),
72+
this.browserConfiguration = const InAppBrowserConfiguration(),
6073
this.webOnlyWindowName,
6174
});
6275

@@ -66,6 +79,9 @@ class LaunchOptions {
6679
/// Configuration for the web view in [PreferredLaunchMode.inAppWebView] mode.
6780
final InAppWebViewConfiguration webViewConfiguration;
6881

82+
/// Configuration for the browser view in [PreferredLaunchMode.inAppBrowserView] mode.
83+
final InAppBrowserConfiguration browserConfiguration;
84+
6985
/// A web-platform-specific option to set the link target.
7086
///
7187
/// Default behaviour when unset should be to open the url in a new tab.

packages/url_launcher/url_launcher_platform_interface/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ repository: https://github.com/flutter/packages/tree/main/packages/url_launcher/
44
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22
55
# NOTE: We strongly prefer non-breaking changes, even at the expense of a
66
# less-clean API. See https://flutter.dev/go/platform-interface-breaking-changes
7-
version: 2.2.1
7+
version: 2.3.0
88

99
environment:
1010
sdk: ">=3.0.0 <4.0.0"
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter_test/flutter_test.dart';
6+
import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart';
7+
8+
void main() {
9+
test('InAppBrowserConfiguration defaults to showTitle false', () {
10+
expect(const InAppBrowserConfiguration().showTitle, false);
11+
});
12+
13+
test('InAppBrowserConfiguration showTitle can be set to true', () {
14+
expect(const InAppBrowserConfiguration(showTitle: true).showTitle, true);
15+
});
16+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
// Copyright 2013 The Flutter Authors. All rights reserved.
2+
// Use of this source code is governed by a BSD-style license that can be
3+
// found in the LICENSE file.
4+
5+
import 'package:flutter_test/flutter_test.dart';
6+
import 'package:url_launcher_platform_interface/url_launcher_platform_interface.dart';
7+
8+
void main() {
9+
test('LaunchOptions have default InAppBrowserConfiguration when not passed',
10+
() {
11+
expect(
12+
const LaunchOptions().browserConfiguration,
13+
const InAppBrowserConfiguration(),
14+
);
15+
});
16+
17+
test('passing non-default InAppBrowserConfiguration to LaunchOptions works',
18+
() {
19+
const InAppBrowserConfiguration browserConfiguration =
20+
InAppBrowserConfiguration(showTitle: true);
21+
22+
const LaunchOptions launchOptions = LaunchOptions(
23+
browserConfiguration: browserConfiguration,
24+
);
25+
26+
expect(launchOptions.browserConfiguration, browserConfiguration);
27+
});
28+
}

0 commit comments

Comments
 (0)