Fix SafeArea DartPad sample (#159344)

This pull request fixes a bug I introduced in
https://github.com/flutter/flutter/pull/158019.

<br>

<h3 align="center">Before</h3>
<p align="center">
  <img 

src="https://github.com/user-attachments/assets/fcb68fac-9c63-445d-8d2b-afc28c685053"
    alt="RenderFlex overflowed"
    width="523px"
  />
</p>

<h3 align="center">After</h3>
<p align="center">
  <img 

src="https://github.com/user-attachments/assets/82091c6a-b3c5-4994-978e-5e76cbb7edfd"
    alt="RenderFlex overflowed"
    width="523px"
  />
</p>

<br><br>

- fixes https://github.com/flutter/flutter/issues/159340
This commit is contained in:
Nate Wilson
2024-12-09 12:54:08 -07:00
committed by GitHub
parent f7871352fb
commit dc5809309a
2 changed files with 31 additions and 2 deletions

View File

@@ -81,4 +81,33 @@ void main() {
context = tester.element(find.text('safe area!'));
expect(MediaQuery.paddingOf(context), EdgeInsets.zero);
});
// Regression test for https://github.com/flutter/flutter/issues/159340.
testWidgets('App displays without layout issues', (WidgetTester tester) async {
// Set the app's size to to match the default DartPad demo screen.
await tester.pumpWidget(
const Center(
child: SizedBox(
width: 500.0,
height: 480.0,
child: example.Insets(),
),
),
);
double appScreenHeight() => tester.getRect(find.byType(example.Insets)).height;
expect(appScreenHeight(), 480);
expect(insetsState.insets, const EdgeInsets.fromLTRB(8.0, 25.0, 8.0, 12.0));
// Drag each slider to its maximum value.
for (int index = 0; index < 3; index++) {
await tester.drag(find.byType(Slider).at(index), const Offset(500.0, 0.0));
await tester.pumpAndSettle();
expect(tester.takeException(), isNull);
}
expect(appScreenHeight(), 480);
expect(insetsState.insets, const EdgeInsets.all(50));
});
}