Unverified Commit 5c96642f authored by Taha Tesser's avatar Taha Tesser Committed by GitHub

Update menu examples for `SafeArea` (#132390)

fixes [Some of the menu examples don't contain `SafeArea`](https://github.com/flutter/flutter/issues/132388)

### Description

This fixes the menu examples for running on mobile with a safe area.

![Group 2](https://github.com/flutter/flutter/assets/48603081/0d460c00-60f5-45e0-87ee-c010ede9ee42)
parent 491ba230
......@@ -101,8 +101,9 @@ class MenuApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(body: MyCheckboxMenu(message: kMessage)),
return MaterialApp(
theme: ThemeData(useMaterial3: true),
home: const Scaffold(body: SafeArea(child: MyCheckboxMenu(message: kMessage))),
);
}
}
......@@ -110,7 +110,7 @@ class MenuAcceleratorApp extends StatelessWidget {
debugDumpApp();
}),
},
child: const Scaffold(body: MyMenuBar()),
child: const Scaffold(body: SafeArea(child: MyMenuBar())),
),
);
}
......
......@@ -204,7 +204,7 @@ class MenuApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
theme: ThemeData(useMaterial3: true),
home: const Scaffold(body: MyCascadingMenu(message: kMessage)),
home: const Scaffold(body: SafeArea(child: MyCascadingMenu(message: kMessage))),
);
}
}
......@@ -230,7 +230,7 @@ class MenuBarApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(body: MyMenuBar(message: kMessage)),
home: Scaffold(body: SafeArea(child: MyMenuBar(message: kMessage))),
);
}
}
......@@ -107,8 +107,9 @@ class MenuApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return const MaterialApp(
home: Scaffold(body: MyRadioMenu()),
return MaterialApp(
theme: ThemeData(useMaterial3: true),
home: const Scaffold(body: SafeArea(child: MyRadioMenu())),
);
}
}
......@@ -24,4 +24,18 @@ void main() {
expect(find.text('Show Message'), findsNothing);
expect(find.text(example.MenuApp.kMessage), findsOneWidget);
});
testWidgets('MenuAnchor is wrapped in a SafeArea', (WidgetTester tester) async {
const double safeAreaPadding = 100.0;
await tester.pumpWidget(
const MediaQuery(
data: MediaQueryData(
padding: EdgeInsets.symmetric(vertical: safeAreaPadding),
),
child: example.MenuApp(),
),
);
expect(tester.getTopLeft(find.byType(MenuAnchor)), const Offset(0.0, safeAreaPadding));
});
}
......@@ -51,4 +51,18 @@ void main() {
await tester.pumpAndSettle();
expect(find.text('Close'), findsNothing);
});
testWidgets('MenuBar is wrapped in a SafeArea', (WidgetTester tester) async {
const double safeAreaPadding = 100.0;
await tester.pumpWidget(
const MediaQuery(
data: MediaQueryData(
padding: EdgeInsets.symmetric(vertical: safeAreaPadding),
),
child: example.MenuAcceleratorApp(),
),
);
expect(tester.getTopLeft(find.byType(MenuBar)), const Offset(0.0, safeAreaPadding));
});
}
......@@ -104,4 +104,18 @@ void main() {
expect(find.text('Last Selected: ${example.MenuEntry.colorBlue.label}'), findsOneWidget);
});
testWidgets('MenuAnchor is wrapped in a SafeArea', (WidgetTester tester) async {
const double safeAreaPadding = 100.0;
await tester.pumpWidget(
const MediaQuery(
data: MediaQueryData(
padding: EdgeInsets.symmetric(vertical: safeAreaPadding),
),
child: example.MenuApp(),
),
);
expect(tester.getTopLeft(find.byType(MenuAnchor)), const Offset(0.0, safeAreaPadding));
});
}
......@@ -91,4 +91,18 @@ void main() {
expect(find.text('Last Selected: Blue Background'), findsOneWidget);
});
testWidgets('MenuBar is wrapped in a SafeArea', (WidgetTester tester) async {
const double safeAreaPadding = 100.0;
await tester.pumpWidget(
const MediaQuery(
data: MediaQueryData(
padding: EdgeInsets.symmetric(vertical: safeAreaPadding),
),
child: example.MenuBarApp(),
),
);
expect(tester.getTopLeft(find.byType(MenuBar)), const Offset(0.0, safeAreaPadding));
});
}
......@@ -74,4 +74,18 @@ void main() {
expect(tester.widget<Radio<Color>>(find.descendant(of: find.byType(RadioMenuButton<Color>).at(2), matching: find.byType(Radio<Color>))).groupValue, equals(Colors.blue));
expect(tester.widget<Container>(find.byType(Container)).color, equals(Colors.blue));
});
testWidgets('MenuAnchor is wrapped in a SafeArea', (WidgetTester tester) async {
const double safeAreaPadding = 100.0;
await tester.pumpWidget(
const MediaQuery(
data: MediaQueryData(
padding: EdgeInsets.symmetric(vertical: safeAreaPadding),
),
child: example.MenuApp(),
),
);
expect(tester.getTopLeft(find.byType(MenuAnchor)), const Offset(0.0, safeAreaPadding));
});
}
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment