Skip to content

Commit 673023b

Browse files
authored
Make sure that a DropdownMenu doesn't crash in 0x0 environment (flutter#174809)
This is my attempt to handle flutter#6537 for the DropdownMenu widget.
1 parent b05f001 commit 673023b

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

packages/flutter/test/material/dropdown_menu_test.dart

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4853,6 +4853,30 @@ void main() {
48534853
expect(controller.text, TestMenu.mainMenu1.label);
48544854
},
48554855
);
4856+
4857+
testWidgets('DropdownMenu does not crash at zero area', (WidgetTester tester) async {
4858+
tester.view.physicalSize = Size.zero;
4859+
final TextEditingController controller = TextEditingController(text: 'I');
4860+
addTearDown(controller.dispose);
4861+
addTearDown(tester.view.reset);
4862+
4863+
await tester.pumpWidget(
4864+
MaterialApp(
4865+
home: Scaffold(
4866+
body: Center(
4867+
child: DropdownMenu<TestMenu>(
4868+
dropdownMenuEntries: menuChildren,
4869+
controller: controller,
4870+
),
4871+
),
4872+
),
4873+
),
4874+
);
4875+
expect(tester.getSize(find.byType(DropdownMenu<TestMenu>)), Size.zero);
4876+
controller.selection = const TextSelection.collapsed(offset: 0);
4877+
await tester.pump();
4878+
expect(find.byType(MenuItemButton), findsWidgets);
4879+
});
48564880
}
48574881

48584882
enum TestMenu {

0 commit comments

Comments
 (0)