mirror of
https://github.com/flutter/flutter.git
synced 2026-01-19 12:12:02 +08:00
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:
parent
f7871352fb
commit
dc5809309a
@ -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: <Widget>[
|
||||
const SizedBox(height: 14),
|
||||
const SizedBox(height: 6),
|
||||
Builder(
|
||||
builder: (BuildContext context) => Text(
|
||||
Toggle.safeArea.of(context) ? 'safe area!' : 'no safe area',
|
||||
|
||||
@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user