Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.

Commit 971d6c3

Browse files
authored
Prepare plugin repo for binding API improvements. (#4136)
1 parent f466ccc commit 971d6c3

File tree

7 files changed

+52
-14
lines changed

7 files changed

+52
-14
lines changed

packages/url_launcher/url_launcher/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 6.0.9
2+
3+
* Silenced warnings that may occur during build when using a very
4+
recent version of Flutter relating to null safety.
5+
16
## 6.0.8
27

38
* Adding API level 30 required package visibility configuration to the example's AndroidManifest.xml and README

packages/url_launcher/url_launcher/lib/url_launcher.dart

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -84,10 +84,13 @@ Future<bool> launch(
8484
bool previousAutomaticSystemUiAdjustment = true;
8585
if (statusBarBrightness != null &&
8686
defaultTargetPlatform == TargetPlatform.iOS &&
87-
WidgetsBinding.instance != null) {
88-
previousAutomaticSystemUiAdjustment =
89-
WidgetsBinding.instance!.renderView.automaticSystemUiAdjustment;
90-
WidgetsBinding.instance!.renderView.automaticSystemUiAdjustment = false;
87+
_ambiguate(WidgetsBinding.instance) != null) {
88+
previousAutomaticSystemUiAdjustment = _ambiguate(WidgetsBinding.instance)!
89+
.renderView
90+
.automaticSystemUiAdjustment;
91+
_ambiguate(WidgetsBinding.instance)!
92+
.renderView
93+
.automaticSystemUiAdjustment = false;
9194
SystemChrome.setSystemUIOverlayStyle(statusBarBrightness == Brightness.light
9295
? SystemUiOverlayStyle.dark
9396
: SystemUiOverlayStyle.light);
@@ -104,9 +107,11 @@ Future<bool> launch(
104107
webOnlyWindowName: webOnlyWindowName,
105108
);
106109

107-
if (statusBarBrightness != null && WidgetsBinding.instance != null) {
108-
WidgetsBinding.instance!.renderView.automaticSystemUiAdjustment =
109-
previousAutomaticSystemUiAdjustment;
110+
if (statusBarBrightness != null &&
111+
_ambiguate(WidgetsBinding.instance) != null) {
112+
_ambiguate(WidgetsBinding.instance)!
113+
.renderView
114+
.automaticSystemUiAdjustment = previousAutomaticSystemUiAdjustment;
110115
}
111116

112117
return result;
@@ -139,3 +144,10 @@ Future<bool> canLaunch(String urlString) async {
139144
Future<void> closeWebView() async {
140145
return await UrlLauncherPlatform.instance.closeWebView();
141146
}
147+
148+
/// This allows a value of type T or T? to be treated as a value of type T?.
149+
///
150+
/// We use this so that APIs that have become non-nullable can still be used
151+
/// with `!` and `?` on the stable branch.
152+
// TODO(ianh): Remove this once we roll stable in late 2021.
153+
T? _ambiguate<T>(T? value) => value;

packages/url_launcher/url_launcher/pubspec.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description: Flutter plugin for launching a URL. Supports
33
web, phone, SMS, and email schemes.
44
repository: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher
55
issue_tracker: https://github.com/flutter/flutter/issues?q=is%3Aissue+is%3Aopen+label%3A%22p%3A+url_launcher%22
6-
version: 6.0.8
6+
version: 6.0.9
77

88
environment:
99
sdk: ">=2.12.0 <3.0.0"

packages/url_launcher/url_launcher/test/url_launcher_test.dart

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ void main() {
239239
..setResponse(true);
240240

241241
final TestWidgetsFlutterBinding binding =
242-
TestWidgetsFlutterBinding.ensureInitialized()
242+
_anonymize(TestWidgetsFlutterBinding.ensureInitialized())
243243
as TestWidgetsFlutterBinding;
244244
debugDefaultTargetPlatformOverride = TargetPlatform.iOS;
245245
binding.renderView.automaticSystemUiAdjustment = true;
@@ -268,7 +268,7 @@ void main() {
268268
..setResponse(true);
269269

270270
final TestWidgetsFlutterBinding binding =
271-
TestWidgetsFlutterBinding.ensureInitialized()
271+
_anonymize(TestWidgetsFlutterBinding.ensureInitialized())
272272
as TestWidgetsFlutterBinding;
273273
debugDefaultTargetPlatformOverride = TargetPlatform.android;
274274
expect(binding.renderView.automaticSystemUiAdjustment, true);
@@ -283,3 +283,11 @@ void main() {
283283
});
284284
});
285285
}
286+
287+
/// This removes the type information from a value so that it can be cast
288+
/// to another type even if that cast is redundant.
289+
///
290+
/// We use this so that APIs whose type have become more descriptive can still
291+
/// be used on the stable branch where they require a cast.
292+
// TODO(ianh): Remove this once we roll stable in late 2021.
293+
Object? _anonymize<T>(T? value) => value;

packages/url_launcher/url_launcher_platform_interface/CHANGELOG.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
## 2.0.4
2+
3+
* Silenced warnings that may occur during build when using a very
4+
recent version of Flutter relating to null safety.
5+
16
## 2.0.3
27

38
* Migrate `pushRouteNameToFramework` to use ChannelBuffers API.

packages/url_launcher/url_launcher_platform_interface/lib/link.dart

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -87,9 +87,10 @@ typedef _SendMessage = Function(String, ByteData?, void Function(ByteData?));
8787
Future<ByteData> pushRouteNameToFramework(Object? _, String routeName) {
8888
final Completer<ByteData> completer = Completer<ByteData>();
8989
SystemNavigator.routeInformationUpdated(location: routeName);
90-
final _SendMessage sendMessage =
91-
WidgetsBinding.instance?.platformDispatcher.onPlatformMessage ??
92-
ui.channelBuffers.push;
90+
final _SendMessage sendMessage = _ambiguate(WidgetsBinding.instance)
91+
?.platformDispatcher
92+
.onPlatformMessage ??
93+
ui.channelBuffers.push;
9394
sendMessage(
9495
'flutter/navigation',
9596
_codec.encodeMethodCall(
@@ -102,3 +103,10 @@ Future<ByteData> pushRouteNameToFramework(Object? _, String routeName) {
102103
);
103104
return completer.future;
104105
}
106+
107+
/// This allows a value of type T or T? to be treated as a value of type T?.
108+
///
109+
/// We use this so that APIs that have become non-nullable can still be used
110+
/// with `!` and `?` on the stable branch.
111+
// TODO(ianh): Remove this once we roll stable in late 2021.
112+
T? _ambiguate<T>(T? value) => value;

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/plugins/tree/master/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.0.3
7+
version: 2.0.4
88

99
environment:
1010
sdk: ">=2.12.0 <3.0.0"

0 commit comments

Comments
 (0)