Unverified Commit f0e32fc6 authored by Hans Muller's avatar Hans Muller Committed by GitHub

Updated Menu examples (#128080)

parent ffe94a22
...@@ -103,6 +103,7 @@ class MenuAcceleratorApp extends StatelessWidget { ...@@ -103,6 +103,7 @@ class MenuAcceleratorApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return MaterialApp( return MaterialApp(
theme: ThemeData(useMaterial3: true),
home: Shortcuts( home: Shortcuts(
shortcuts: <ShortcutActivator, Intent>{ shortcuts: <ShortcutActivator, Intent>{
const SingleActivator(LogicalKeyboardKey.keyT, control: true): VoidCallbackIntent(() { const SingleActivator(LogicalKeyboardKey.keyT, control: true): VoidCallbackIntent(() {
......
...@@ -202,8 +202,9 @@ class MenuApp extends StatelessWidget { ...@@ -202,8 +202,9 @@ class MenuApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return const MaterialApp( return MaterialApp(
home: Scaffold(body: MyCascadingMenu(message: kMessage)), theme: ThemeData(useMaterial3: true),
home: const Scaffold(body: MyCascadingMenu(message: kMessage)),
); );
} }
} }
...@@ -201,8 +201,9 @@ class ContextMenuApp extends StatelessWidget { ...@@ -201,8 +201,9 @@ class ContextMenuApp extends StatelessWidget {
@override @override
Widget build(BuildContext context) { Widget build(BuildContext context) {
return const MaterialApp( return MaterialApp(
home: Scaffold(body: MyContextMenu(message: kMessage)), theme: ThemeData(useMaterial3: true),
home: const Scaffold(body: MyContextMenu(message: kMessage)),
); );
} }
} }
...@@ -29,7 +29,7 @@ void main() { ...@@ -29,7 +29,7 @@ void main() {
expect(find.text('About', findRichText: true), findsOneWidget); expect(find.text('About', findRichText: true), findsOneWidget);
expect( expect(
tester.getRect(findMenu('About')), tester.getRect(findMenu('About')),
equals(const Rect.fromLTRB(4.0, 48.0, 98.0, 208.0)), equals(const Rect.fromLTRB(4.0, 48.0, 111.0, 208.0)),
); );
expect(find.text('Save', findRichText: true), findsOneWidget); expect(find.text('Save', findRichText: true), findsOneWidget);
expect(find.text('Quit', findRichText: true), findsOneWidget); expect(find.text('Quit', findRichText: true), findsOneWidget);
...@@ -45,10 +45,10 @@ void main() { ...@@ -45,10 +45,10 @@ void main() {
expect(find.text('Quit', findRichText: true), findsNothing); expect(find.text('Quit', findRichText: true), findsNothing);
expect(find.text('Magnify', findRichText: true), findsNothing); expect(find.text('Magnify', findRichText: true), findsNothing);
expect(find.text('Minify', findRichText: true), findsNothing); expect(find.text('Minify', findRichText: true), findsNothing);
expect(find.text('CLOSE'), findsOneWidget); expect(find.text('Close'), findsOneWidget);
await tester.tap(find.text('CLOSE')); await tester.tap(find.text('Close'));
await tester.pumpAndSettle(); await tester.pumpAndSettle();
expect(find.text('CLOSE'), findsNothing); expect(find.text('Close'), findsNothing);
}); });
} }
...@@ -21,14 +21,14 @@ void main() { ...@@ -21,14 +21,14 @@ void main() {
await tester.sendKeyDownEvent(LogicalKeyboardKey.controlRight); await tester.sendKeyDownEvent(LogicalKeyboardKey.controlRight);
await tester.tapAt(const Offset(100, 200)); await tester.tapAt(const Offset(100, 200));
await tester.pump(); await tester.pump();
expect(tester.getRect(findMenu()), equals(const Rect.fromLTRB(100.0, 200.0, 388.0, 360.0))); expect(tester.getRect(findMenu()), equals(const Rect.fromLTRB(100.0, 200.0, 433.0, 360.0)));
// Make sure tapping in a different place causes the menu to move. // Make sure tapping in a different place causes the menu to move.
await tester.tapAt(const Offset(200, 100)); await tester.tapAt(const Offset(200, 100));
await tester.pump(); await tester.pump();
await tester.sendKeyUpEvent(LogicalKeyboardKey.controlRight); await tester.sendKeyUpEvent(LogicalKeyboardKey.controlRight);
expect(tester.getRect(findMenu()), equals(const Rect.fromLTRB(200.0, 100.0, 488.0, 260.0))); expect(tester.getRect(findMenu()), equals(const Rect.fromLTRB(200.0, 100.0, 533.0, 260.0)));
expect(find.text(example.MenuEntry.about.label), findsOneWidget); expect(find.text(example.MenuEntry.about.label), findsOneWidget);
expect(find.text(example.MenuEntry.showMessage.label), findsOneWidget); expect(find.text(example.MenuEntry.showMessage.label), findsOneWidget);
......
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