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:
@@ -26,7 +26,7 @@ class SafeAreaExampleApp extends StatelessWidget {
|
|||||||
scaffoldBackgroundColor: const Color(0xFFD0FFE8),
|
scaffoldBackgroundColor: const Color(0xFFD0FFE8),
|
||||||
listTileTheme: const ListTileThemeData(
|
listTileTheme: const ListTileThemeData(
|
||||||
tileColor: Colors.white70,
|
tileColor: Colors.white70,
|
||||||
contentPadding: EdgeInsets.all(6.0),
|
visualDensity: VisualDensity(horizontal: -4, vertical: -4),
|
||||||
),
|
),
|
||||||
appBarTheme: AppBarTheme(
|
appBarTheme: AppBarTheme(
|
||||||
backgroundColor: colors.secondary,
|
backgroundColor: colors.secondary,
|
||||||
@@ -65,7 +65,7 @@ class SafeAreaExample extends StatelessWidget {
|
|||||||
|
|
||||||
static final Widget controls = Column(
|
static final Widget controls = Column(
|
||||||
children: <Widget>[
|
children: <Widget>[
|
||||||
const SizedBox(height: 14),
|
const SizedBox(height: 6),
|
||||||
Builder(
|
Builder(
|
||||||
builder: (BuildContext context) => Text(
|
builder: (BuildContext context) => Text(
|
||||||
Toggle.safeArea.of(context) ? 'safe area!' : 'no safe area',
|
Toggle.safeArea.of(context) ? 'safe area!' : 'no safe area',
|
||||||
|
|||||||
@@ -81,4 +81,33 @@ void main() {
|
|||||||
context = tester.element(find.text('safe area!'));
|
context = tester.element(find.text('safe area!'));
|
||||||
expect(MediaQuery.paddingOf(context), EdgeInsets.zero);
|
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));
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user