diff --git a/packages/flutter/lib/src/material/popup_menu.dart b/packages/flutter/lib/src/material/popup_menu.dart index cc87623e6330..4d81e0959daa 100644 --- a/packages/flutter/lib/src/material/popup_menu.dart +++ b/packages/flutter/lib/src/material/popup_menu.dart @@ -486,6 +486,7 @@ class CheckedPopupMenuItem extends PopupMenuItem { super.labelTextStyle, super.mouseCursor, super.child, + super.onTap, }); /// Whether to display a checkmark next to the menu item. diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index fcc0fa1f8063..79e3a7f6f6b1 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -3740,6 +3740,51 @@ void main() { expect(_labelStyle(tester, 'Item 1')!.fontWeight, customTextStyle.fontWeight); expect(_labelStyle(tester, 'Item 1')!.fontStyle, customTextStyle.fontStyle); }); + + testWidgets('CheckedPopupMenuItem.onTap callback is called when defined', (WidgetTester tester) async { + int count = 0; + await tester.pumpWidget( + TestApp( + textDirection: TextDirection.ltr, + child: Material( + child: RepaintBoundary( + child: PopupMenuButton( + child: const Text('button'), + itemBuilder: (BuildContext context) { + return >[ + CheckedPopupMenuItem( + onTap: () { + count += 1; + }, + value: 'item1', + child: const Text('Item with onTap'), + ), + const CheckedPopupMenuItem( + value: 'item2', + child: Text('Item without onTap'), + ), + ]; + }, + ), + ), + ), + ), + ); + + // Tap a checked menu item with onTap. + await tester.tap(find.text('button')); + await tester.pumpAndSettle(); + await tester.tap(find.widgetWithText(CheckedPopupMenuItem, 'Item with onTap')); + await tester.pumpAndSettle(); + expect(count, 1); + + // Tap a checked menu item without onTap. + await tester.tap(find.text('button')); + await tester.pumpAndSettle(); + await tester.tap(find.widgetWithText(CheckedPopupMenuItem, 'Item without onTap')); + await tester.pumpAndSettle(); + expect(count, 1); + }); } class TestApp extends StatelessWidget {