Skip to content
This repository was archived by the owner on Feb 22, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from 2 commits
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
4 changes: 4 additions & 0 deletions packages/url_launcher/url_launcher/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
## 5.4.8

* Initialize `previousAutomaticSystemUiAdjustment` in launch method.

## 5.4.7

* Update lower bound of dart dependency to 2.1.0.
Expand Down
3 changes: 2 additions & 1 deletion packages/url_launcher/url_launcher/lib/url_launcher.dart
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ Future<bool> launch(
message: 'To use webview or safariVC, you need to pass'
'in a web URL. This $urlString is not a web URL.');
}
bool previousAutomaticSystemUiAdjustment;
bool previousAutomaticSystemUiAdjustment = true;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you know why true instead of false? Could you add a comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just added a comment. I think it should be true because if it's false when the statusBarBrightness is set, then there will be a delay in computing the system UI.

if (statusBarBrightness != null &&
defaultTargetPlatform == TargetPlatform.iOS) {
previousAutomaticSystemUiAdjustment =
Expand All @@ -92,6 +92,7 @@ Future<bool> launch(
universalLinksOnly: universalLinksOnly ?? false,
headers: headers ?? <String, String>{},
);
assert(previousAutomaticSystemUiAdjustment != null);
if (statusBarBrightness != null) {
WidgetsBinding.instance.renderView.automaticSystemUiAdjustment =
previousAutomaticSystemUiAdjustment;
Expand Down
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 @@ -2,7 +2,7 @@ name: url_launcher
description: Flutter plugin for launching a URL on Android and iOS. Supports
web, phone, SMS, and email schemes.
homepage: https://github.com/flutter/plugins/tree/master/packages/url_launcher/url_launcher
version: 5.4.7
version: 5.4.8

flutter:
plugin:
Expand Down
15 changes: 15 additions & 0 deletions packages/url_launcher/url_launcher/test/url_launcher_test.dart
Original file line number Diff line number Diff line change
Expand Up @@ -205,6 +205,21 @@ void main() {
await launchResult;
expect(binding.renderView.automaticSystemUiAdjustment, isTrue);
});

test('sets automaticSystemUiAdjustment to not be null', () async {
final TestWidgetsFlutterBinding binding =
TestWidgetsFlutterBinding.ensureInitialized();
debugDefaultTargetPlatformOverride = TargetPlatform.android;
expect(binding.renderView.automaticSystemUiAdjustment, isNotNull);
final Future<bool> launchResult =
launch('http://flutter.dev/', statusBarBrightness: Brightness.dark);

// The automaticSystemUiAdjustment should be set before the launch
// and not null after the launch result is complete.
expect(binding.renderView.automaticSystemUiAdjustment, isNotNull);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do you want to be more precise here and below and expect that this is true?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes it should be true. I updated and ran the test again.

await launchResult;
expect(binding.renderView.automaticSystemUiAdjustment, isNotNull);
});
});
}

Expand Down