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

Conversation

@yjbanov
Copy link
Contributor

@yjbanov yjbanov commented Sep 19, 2022

Fix the mapping of Flutter screen orientation values to window.screen.orientation.lock equivalents. Our previous tests were broken too. They weren't testing what they thought they were testing (e.g. js_util.setProperty(screen, 'orientation', null) is a noop). This PR fixes tests as well.

Bonus: remove the no longer necessary unsafeIsNull. In the past we used it with dart:html, where dart:html used incorrect nullability annotations, we needed a way to null check non-nullable types. That's gone, and whatever remained works perfectly fine with just == null and != null.

Fixes flutter/flutter#88269

@flutter-dashboard flutter-dashboard bot added the platform-web Code specifically for the web engine label Sep 19, 2022
@yjbanov yjbanov marked this pull request as ready for review September 19, 2022 17:06
///
/// See w3c screen api: https://www.w3.org/TR/screen-orientation/
Future<bool> setPreferredOrientation(List<dynamic> orientations) {
final DomScreen screen = domWindow.screen!;
Copy link
Contributor

Choose a reason for hiding this comment

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

😮

Comment on lines 1307 to 1309
if (jsResult is Future) {
return jsResult;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This check seems fine to me, but I don't know if this is the right place for it. Maybe js_util.promiseToFuture should do this check internally? I'm not sure.

Or like you said, maybe allowInterop should convert futures to promises.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Actually, I changed the test to use the Promise API directly, so there's no futures to convert. Looks much better now. The point about allowInterop limitation still stands though, although less relevant to this PR now.

@yjbanov yjbanov added the autosubmit Merge PR when tree becomes green via auto submit App label Sep 19, 2022
@auto-submit auto-submit bot merged commit b43cc88 into flutter:main Sep 19, 2022
engine-flutter-autoroll added a commit to engine-flutter-autoroll/flutter that referenced this pull request Sep 19, 2022
Oleh-Sv pushed a commit to Oleh-Sv/engine that referenced this pull request Sep 28, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

autosubmit Merge PR when tree becomes green via auto submit App platform-web Code specifically for the web engine

Projects

None yet

Development

Successfully merging this pull request may close these issues.

SystemChrome.setPreferredOrientations uses wrong orientation types on Web

2 participants