Skip to content

Commit 480869a

Browse files
authored
Update MenuAnchor API examples (#156404)
## Description Cleanup MenuAnchor API examples: - Remove usage of useMaterial3 - fix some formatting issues
1 parent 34457fe commit 480869a

File tree

5 files changed

+10
-14
lines changed

5 files changed

+10
-14
lines changed

examples/api/lib/material/menu_anchor/checkbox_menu_button.0.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,9 +101,8 @@ class MenuApp extends StatelessWidget {
101101

102102
@override
103103
Widget build(BuildContext context) {
104-
return MaterialApp(
105-
theme: ThemeData(useMaterial3: true),
106-
home: const Scaffold(body: SafeArea(child: MyCheckboxMenu(message: kMessage))),
104+
return const MaterialApp(
105+
home: Scaffold(body: SafeArea(child: MyCheckboxMenu(message: kMessage))),
107106
);
108107
}
109108
}

examples/api/lib/material/menu_anchor/menu_accelerator_label.0.dart

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,6 @@ class MenuAcceleratorApp extends StatelessWidget {
103103
@override
104104
Widget build(BuildContext context) {
105105
return MaterialApp(
106-
theme: ThemeData(useMaterial3: true),
107106
home: Shortcuts(
108107
shortcuts: <ShortcutActivator, Intent>{
109108
const SingleActivator(LogicalKeyboardKey.keyT, control: true): VoidCallbackIntent(() {

examples/api/lib/material/menu_anchor/menu_anchor.0.dart

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -202,9 +202,8 @@ class MenuApp extends StatelessWidget {
202202

203203
@override
204204
Widget build(BuildContext context) {
205-
return MaterialApp(
206-
theme: ThemeData(useMaterial3: true),
207-
home: const Scaffold(body: SafeArea(child: MyCascadingMenu(message: kMessage))),
205+
return const MaterialApp(
206+
home: Scaffold(body: SafeArea(child: MyCascadingMenu(message: kMessage))),
208207
);
209208
}
210209
}

examples/api/lib/material/menu_anchor/menu_anchor.2.dart

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
66

77
/// Flutter code sample for [MenuAnchor].
88
9-
109
void main() => runApp(const MenuAnchorApp());
1110

1211
// This is the type used by the menu below.
@@ -17,9 +16,8 @@ class MenuAnchorApp extends StatelessWidget {
1716

1817
@override
1918
Widget build(BuildContext context) {
20-
return MaterialApp(
21-
theme: ThemeData(useMaterial3: true),
22-
home: const MenuAnchorExample(),
19+
return const MaterialApp(
20+
home: MenuAnchorExample(),
2321
);
2422
}
2523
}
@@ -43,8 +41,7 @@ class _MenuAnchorExampleState extends State<MenuAnchorExample> {
4341
),
4442
body: Center(
4543
child: MenuAnchor(
46-
builder:
47-
(BuildContext context, MenuController controller, Widget? child) {
44+
builder: (BuildContext context, MenuController controller, Widget? child) {
4845
return IconButton(
4946
onPressed: () {
5047
if (controller.isOpen) {
@@ -55,7 +52,8 @@ class _MenuAnchorExampleState extends State<MenuAnchorExample> {
5552
},
5653
icon: const Icon(Icons.more_horiz),
5754
tooltip: 'Show menu',
58-
);},
55+
);
56+
},
5957
menuChildren: List<MenuItemButton>.generate(
6058
3,
6159
(int index) => MenuItemButton(

examples/api/test/material/menu_anchor/menu_bar.0_test.dart

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ void main() {
5151
expect(find.text(example.MenuBarApp.kMessage), findsOneWidget);
5252
expect(find.text('Last Selected: Show Message'), findsOneWidget);
5353
});
54+
5455
testWidgets('Shortcuts work', (WidgetTester tester) async {
5556
await tester.pumpWidget(
5657
const example.MenuBarApp(),

0 commit comments

Comments
 (0)