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 <dkwingsmt@users.noreply.github.com>
This commit is contained in:
Ahmed Mohamed Sameh 2025-11-03 08:40:30 +02:00 committed by GitHub
parent 50d03ed339
commit f07d882efb
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -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<String>(child: Text('X'))),
),
),
),
);
expect(tester.getSize(find.byType(PopupMenuItem<String>)), 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