Update MenuAnchor API examples (#156404)
## Description Cleanup MenuAnchor API examples: - Remove usage of useMaterial3 - fix some formatting issues
This commit is contained in:
parent
34457fe1f5
commit
480869afe7
@ -101,9 +101,8 @@ class MenuApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
home: const Scaffold(body: SafeArea(child: MyCheckboxMenu(message: kMessage))),
|
||||
return const MaterialApp(
|
||||
home: Scaffold(body: SafeArea(child: MyCheckboxMenu(message: kMessage))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -103,7 +103,6 @@ class MenuAcceleratorApp extends StatelessWidget {
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
home: Shortcuts(
|
||||
shortcuts: <ShortcutActivator, Intent>{
|
||||
const SingleActivator(LogicalKeyboardKey.keyT, control: true): VoidCallbackIntent(() {
|
||||
|
@ -202,9 +202,8 @@ class MenuApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
home: const Scaffold(body: SafeArea(child: MyCascadingMenu(message: kMessage))),
|
||||
return const MaterialApp(
|
||||
home: Scaffold(body: SafeArea(child: MyCascadingMenu(message: kMessage))),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
@ -6,7 +6,6 @@ import 'package:flutter/material.dart';
|
||||
|
||||
/// Flutter code sample for [MenuAnchor].
|
||||
|
||||
|
||||
void main() => runApp(const MenuAnchorApp());
|
||||
|
||||
// This is the type used by the menu below.
|
||||
@ -17,9 +16,8 @@ class MenuAnchorApp extends StatelessWidget {
|
||||
|
||||
@override
|
||||
Widget build(BuildContext context) {
|
||||
return MaterialApp(
|
||||
theme: ThemeData(useMaterial3: true),
|
||||
home: const MenuAnchorExample(),
|
||||
return const MaterialApp(
|
||||
home: MenuAnchorExample(),
|
||||
);
|
||||
}
|
||||
}
|
||||
@ -43,8 +41,7 @@ class _MenuAnchorExampleState extends State<MenuAnchorExample> {
|
||||
),
|
||||
body: Center(
|
||||
child: MenuAnchor(
|
||||
builder:
|
||||
(BuildContext context, MenuController controller, Widget? child) {
|
||||
builder: (BuildContext context, MenuController controller, Widget? child) {
|
||||
return IconButton(
|
||||
onPressed: () {
|
||||
if (controller.isOpen) {
|
||||
@ -55,7 +52,8 @@ class _MenuAnchorExampleState extends State<MenuAnchorExample> {
|
||||
},
|
||||
icon: const Icon(Icons.more_horiz),
|
||||
tooltip: 'Show menu',
|
||||
);},
|
||||
);
|
||||
},
|
||||
menuChildren: List<MenuItemButton>.generate(
|
||||
3,
|
||||
(int index) => MenuItemButton(
|
||||
|
@ -51,6 +51,7 @@ void main() {
|
||||
expect(find.text(example.MenuBarApp.kMessage), findsOneWidget);
|
||||
expect(find.text('Last Selected: Show Message'), findsOneWidget);
|
||||
});
|
||||
|
||||
testWidgets('Shortcuts work', (WidgetTester tester) async {
|
||||
await tester.pumpWidget(
|
||||
const example.MenuBarApp(),
|
||||
|
Loading…
x
Reference in New Issue
Block a user