
Test that the position of a cutout as reported by the Android engine repositions based on screen orientation. Related to https://github.com/flutter/engine/pull/55992 Part of https://github.com/flutter/flutter/issues/155658 to test run flutter drive integration_test/display_cutout_test.dart from dev/integration_tests/display_cutout_rotation Pr also force upgrades pub dependencies because I was getting presubmit failure in version solve. ## Pre-launch Checklist - [x] I read the [Contributor Guide] and followed the process outlined there for submitting PRs. - [x] I read the [Tree Hygiene] wiki page, which explains my responsibilities. - [x] I read and followed the [Flutter Style Guide], including [Features we expect every widget to implement]. - [x] I signed the [CLA]. - [x] I listed at least one issue that this PR fixes in the description above. - [x] I updated/added relevant documentation (doc comments with `///`). - [x] I added new tests to check the change I am making, or this PR is [test-exempt]. - [x] I followed the [breaking change policy] and added [Data Driven Fixes] where supported. - [x] All existing and new tests are passing.
51 lines
1.4 KiB
Dart
51 lines
1.4 KiB
Dart
// Copyright 2014 The Flutter Authors. All rights reserved.
|
|
// Use of this source code is governed by a BSD-style license that can be
|
|
// found in the LICENSE file.
|
|
|
|
import 'dart:ui';
|
|
|
|
import 'package:flutter/material.dart';
|
|
|
|
void main() {
|
|
runApp(const MyApp());
|
|
}
|
|
|
|
final class MyApp extends StatefulWidget {
|
|
const MyApp({super.key});
|
|
|
|
@override
|
|
State<MyApp> createState() => _MyAppState();
|
|
}
|
|
|
|
class _MyAppState extends State<MyApp> {
|
|
@override
|
|
Widget build(BuildContext context) {
|
|
final List<DisplayFeature> displayFeatures = MediaQuery.of(context).displayFeatures;
|
|
displayFeatures.retainWhere(
|
|
(DisplayFeature feature) => feature.type == DisplayFeatureType.cutout,
|
|
);
|
|
String text;
|
|
// None of this complexity is required for the test but it helps when
|
|
// visually debugging or watching a video of a remote device.
|
|
if (displayFeatures.isEmpty) {
|
|
text = 'CutoutNone';
|
|
} else if (displayFeatures.length > 1) {
|
|
text = 'CutoutMany';
|
|
} else {
|
|
final Rect cutout = displayFeatures[0].bounds;
|
|
if (cutout.top == 0) {
|
|
text = 'CutoutTop';
|
|
} else if (cutout.left == 0) {
|
|
text = 'CutoutLeft';
|
|
} else {
|
|
text = 'CutoutNeither';
|
|
}
|
|
}
|
|
// Tests assume there is some text element displayed.
|
|
return MaterialApp(
|
|
debugShowCheckedModeBanner: false,
|
|
home: Text('Cutout status: $text', key: Key(text)),
|
|
);
|
|
}
|
|
}
|