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

Commit c70c663

Browse files
committed
Add screen accessor and testing.
1 parent ba660f0 commit c70c663

File tree

2 files changed

+61
-0
lines changed

2 files changed

+61
-0
lines changed

lib/ui/window.dart

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,6 +581,9 @@ abstract class FlutterView {
581581
/// The configuration of this view.
582582
ViewConfiguration/*!*/ get viewConfiguration;
583583

584+
/// The [Screen] that this [FlutterView] is displayed on.
585+
Screen get screen => viewConfiguration.screen;
586+
584587
/// The number of device pixels for each logical pixel for the screen this
585588
/// view is displayed on.
586589
///

testing/dart/window_hooks_integration_test.dart

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -414,5 +414,63 @@ void main() {
414414
expect(window.physicalDepth, 100.0);
415415
expect(window.systemGestureInsets.bottom, 44.0);
416416
});
417+
418+
test('Screen padding/insets/viewPadding/systemGestureInsets', () {
419+
_updateScreenMetrics(
420+
0, // screen id
421+
'S0', // screen name
422+
10.0, // left
423+
11.0, // top
424+
800.0, // width
425+
600.0, // height
426+
2.5, // device pixel ratio
427+
50.0, // padding top
428+
0.0, // padding right
429+
40.0, // padding bottom
430+
0.0, // padding left
431+
0.0, // inset top
432+
0.0, // inset right
433+
0.0, // inset bottom
434+
0.0, // inset left
435+
0.0, // system gesture inset top
436+
0.0, // system gesture inset right
437+
0.0, // system gesture inset bottom
438+
0.0, // system gesture inset left
439+
);
440+
441+
expect(window.screen.configuration.viewInsets.bottom, 0.0);
442+
expect(window.screen.configuration.viewPadding.bottom, 40.0);
443+
expect(window.screen.configuration.padding.bottom, 40.0);
444+
expect(window.screen.configuration.devicePixelRatio, 2.5);
445+
expect(window.screen.configuration.systemGestureInsets.bottom, 0.0);
446+
447+
_updateScreenMetrics(
448+
0, // window id
449+
'S0', // screen name
450+
10.0, // left
451+
11.0, // top
452+
800.0, // width
453+
600.0, // height
454+
2.5, // device pixel ratio
455+
50.0, // padding top
456+
0.0, // padding right
457+
40.0, // padding bottom
458+
0.0, // padding left
459+
0.0, // inset top
460+
0.0, // inset right
461+
400.0, // inset bottom
462+
0.0, // inset left
463+
0.0, // system gesture inset top
464+
0.0, // system gesture inset right
465+
44.0, // system gesture inset bottom
466+
0.0, // system gesture inset left
467+
);
468+
469+
expect(window.screen.configuration.viewInsets.bottom, 400.0);
470+
expect(window.screen.configuration.viewPadding.bottom, 40.0);
471+
expect(window.screen.configuration.padding.bottom, 0.0);
472+
expect(window.screen.configuration.devicePixelRatio, 2.5);
473+
expect(window.screen.configuration.systemGestureInsets.bottom, 44.0);
474+
});
417475
});
418476
}

0 commit comments

Comments
 (0)