Skip to content

Commit 95900da

Browse files
Make sure that an ElevatedButton doesn't crash in 0x0 environment (flutter#175006)
This is my attempt to handle flutter#6537 for the ElevatedButton widget. Co-authored-by: Tong Mu <dkwingsmt@users.noreply.github.com>
1 parent c30e5d4 commit 95900da

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

packages/flutter/test/material/elevated_button_test.dart

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2609,6 +2609,19 @@ void main() {
26092609
expect(iconStyle(tester, buttonIcon).color, hoveredColor);
26102610
});
26112611

2612+
testWidgets('ElevatedButton does not crash at zero area', (WidgetTester tester) async {
2613+
await tester.pumpWidget(
2614+
MaterialApp(
2615+
home: Center(
2616+
child: SizedBox.shrink(
2617+
child: ElevatedButton(onPressed: () {}, child: const Text('X')),
2618+
),
2619+
),
2620+
),
2621+
);
2622+
expect(tester.getSize(find.byType(ElevatedButton)), Size.zero);
2623+
});
2624+
26122625
testWidgets('When an ElevatedButton gains an icon, preserves the same SemanticsNode id', (
26132626
WidgetTester tester,
26142627
) async {

0 commit comments

Comments
 (0)