From f07d882efbe3046c608e83dbee962a0393e5f032 Mon Sep 17 00:00:00 2001 From: Ahmed Mohamed Sameh Date: Mon, 3 Nov 2025 08:40:30 +0200 Subject: [PATCH] Make sure that a PopupMenuItem doesn't crash in 0x0 environment (#177533) This is my attempt to handle https://github.com/flutter/flutter/issues/6537 for the PopupMenuItem widget. Co-authored-by: Tong Mu --- packages/flutter/test/material/popup_menu_test.dart | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/packages/flutter/test/material/popup_menu_test.dart b/packages/flutter/test/material/popup_menu_test.dart index 07ce24eb2f8..4fa08a22e7e 100644 --- a/packages/flutter/test/material/popup_menu_test.dart +++ b/packages/flutter/test/material/popup_menu_test.dart @@ -4851,6 +4851,19 @@ void main() { checkPopupMenu(popupMenuTheme2); }); + testWidgets('PopupMenuItem does not crash at zero area', (WidgetTester tester) async { + await tester.pumpWidget( + const MaterialApp( + home: Scaffold( + body: Center( + child: SizedBox.shrink(child: PopupMenuItem(child: Text('X'))), + ), + ), + ), + ); + expect(tester.getSize(find.byType(PopupMenuItem)), Size.zero); + }); + testWidgets('PopupMenuButton does not crash at zero area', (WidgetTester tester) async { // This test case only verifies the layout of the button itself, not the // overlay, because there doesn't seem to be a way to open the menu at zero