Make sure that a RadioMenuButton doesn't crash in 0x0 environment (#176516)

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

Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
This commit is contained in:
Ahmed Mohamed Sameh 2025-10-09 03:07:14 +03:00 committed by GitHub
parent a2a56c2939
commit e055ca0b91
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -5097,6 +5097,41 @@ void main() {
expect(tester.getRect(findMenuPanels()).width, 800.0 - reservedPadding.horizontal);
});
testWidgets('CheckboxMenuButton does not crash at zero area', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Center(
child: SizedBox.shrink(
child: CheckboxMenuButton(
value: true,
onChanged: (bool? value) {},
child: const Text('X'),
),
),
),
),
);
expect(tester.getSize(find.byType(CheckboxMenuButton)), Size.zero);
});
testWidgets('RadioMenuButton does not crash at zero area', (WidgetTester tester) async {
await tester.pumpWidget(
MaterialApp(
home: Center(
child: SizedBox.shrink(
child: RadioMenuButton<bool>(
value: true,
groupValue: true,
onChanged: (bool? value) {},
child: null,
),
),
),
),
);
expect(tester.getSize(find.byType(RadioMenuButton<bool>)), Size.zero);
});
testWidgets('Layout updates when reserved padding changes', (WidgetTester tester) async {
const EdgeInsetsGeometry reservedPadding = EdgeInsets.symmetric(horizontal: 13.0);