Make sure that a MenuAnchor doesn't crash in 0x0 environment (#176302)

This is my attempt to handle
https://github.com/flutter/flutter/issues/6537 for the MenuAnchor
widget.

---------

Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
This commit is contained in:
Ahmed Mohamed Sameh 2025-11-02 21:59:05 +02:00 committed by GitHub
parent 604bc866a4
commit 285e6f06ad
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5535,6 +5535,25 @@ void main() {
);
expect(tester.getSize(find.byType(CheckboxMenuButton)), Size.zero);
});
testWidgets('MenuAnchor does not crash at zero area', (WidgetTester tester) async {
tester.view.physicalSize = Size.zero;
final MenuController menuController = MenuController();
addTearDown(tester.view.reset);
await tester.pumpWidget(
MaterialApp(
home: Scaffold(
body: Center(
child: MenuAnchor(menuChildren: const <Widget>[Text('X')], controller: menuController),
),
),
),
);
expect(tester.getSize(find.byType(MenuAnchor)), Size.zero);
menuController.open();
await tester.pump();
expect(find.text('X'), findsOne);
});
}
List<Widget> createTestMenus({