diff --git a/examples/api/lib/widgets/safe_area/safe_area.0.dart b/examples/api/lib/widgets/safe_area/safe_area.0.dart index 3c3f8779373..68795c4de72 100644 --- a/examples/api/lib/widgets/safe_area/safe_area.0.dart +++ b/examples/api/lib/widgets/safe_area/safe_area.0.dart @@ -26,7 +26,7 @@ class SafeAreaExampleApp extends StatelessWidget { scaffoldBackgroundColor: const Color(0xFFD0FFE8), listTileTheme: const ListTileThemeData( tileColor: Colors.white70, - contentPadding: EdgeInsets.all(6.0), + visualDensity: VisualDensity(horizontal: -4, vertical: -4), ), appBarTheme: AppBarTheme( backgroundColor: colors.secondary, @@ -65,7 +65,7 @@ class SafeAreaExample extends StatelessWidget { static final Widget controls = Column( children: [ - const SizedBox(height: 14), + const SizedBox(height: 6), Builder( builder: (BuildContext context) => Text( Toggle.safeArea.of(context) ? 'safe area!' : 'no safe area', diff --git a/examples/api/test/widgets/safe_area/safe_area.0_test.dart b/examples/api/test/widgets/safe_area/safe_area.0_test.dart index a0bf4c3d22f..38f772a9cf5 100644 --- a/examples/api/test/widgets/safe_area/safe_area.0_test.dart +++ b/examples/api/test/widgets/safe_area/safe_area.0_test.dart @@ -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)); + }); }