From 480869afe7bcf352bb58bae996a9a371c2937af5 Mon Sep 17 00:00:00 2001 From: Bruno Leroux Date: Tue, 8 Oct 2024 21:15:07 +0200 Subject: [PATCH] Update MenuAnchor API examples (#156404) ## Description Cleanup MenuAnchor API examples: - Remove usage of useMaterial3 - fix some formatting issues --- .../material/menu_anchor/checkbox_menu_button.0.dart | 5 ++--- .../menu_anchor/menu_accelerator_label.0.dart | 1 - .../api/lib/material/menu_anchor/menu_anchor.0.dart | 5 ++--- .../api/lib/material/menu_anchor/menu_anchor.2.dart | 12 +++++------- .../test/material/menu_anchor/menu_bar.0_test.dart | 1 + 5 files changed, 10 insertions(+), 14 deletions(-) diff --git a/examples/api/lib/material/menu_anchor/checkbox_menu_button.0.dart b/examples/api/lib/material/menu_anchor/checkbox_menu_button.0.dart index 8a6066f7ce..b0c3090da1 100644 --- a/examples/api/lib/material/menu_anchor/checkbox_menu_button.0.dart +++ b/examples/api/lib/material/menu_anchor/checkbox_menu_button.0.dart @@ -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))), ); } } diff --git a/examples/api/lib/material/menu_anchor/menu_accelerator_label.0.dart b/examples/api/lib/material/menu_anchor/menu_accelerator_label.0.dart index 5e09ef9328..e27556c5f9 100644 --- a/examples/api/lib/material/menu_anchor/menu_accelerator_label.0.dart +++ b/examples/api/lib/material/menu_anchor/menu_accelerator_label.0.dart @@ -103,7 +103,6 @@ class MenuAcceleratorApp extends StatelessWidget { @override Widget build(BuildContext context) { return MaterialApp( - theme: ThemeData(useMaterial3: true), home: Shortcuts( shortcuts: { const SingleActivator(LogicalKeyboardKey.keyT, control: true): VoidCallbackIntent(() { diff --git a/examples/api/lib/material/menu_anchor/menu_anchor.0.dart b/examples/api/lib/material/menu_anchor/menu_anchor.0.dart index d4a3de7dec..1fdec6a157 100644 --- a/examples/api/lib/material/menu_anchor/menu_anchor.0.dart +++ b/examples/api/lib/material/menu_anchor/menu_anchor.0.dart @@ -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))), ); } } diff --git a/examples/api/lib/material/menu_anchor/menu_anchor.2.dart b/examples/api/lib/material/menu_anchor/menu_anchor.2.dart index 7c241d3c5f..0cfe7d21d3 100644 --- a/examples/api/lib/material/menu_anchor/menu_anchor.2.dart +++ b/examples/api/lib/material/menu_anchor/menu_anchor.2.dart @@ -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 { ), 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 { }, icon: const Icon(Icons.more_horiz), tooltip: 'Show menu', - );}, + ); + }, menuChildren: List.generate( 3, (int index) => MenuItemButton( diff --git a/examples/api/test/material/menu_anchor/menu_bar.0_test.dart b/examples/api/test/material/menu_anchor/menu_bar.0_test.dart index 1ba69519c1..25a02ede01 100644 --- a/examples/api/test/material/menu_anchor/menu_bar.0_test.dart +++ b/examples/api/test/material/menu_anchor/menu_bar.0_test.dart @@ -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(),