Skip to content

Commit 46c3f84

Browse files
authored
Make sure that a SegmentedButton doesn't crash in 0x0 environment (flutter#177773)
This is my attempt to handle flutter#6537 for the SegmentedButton widget.
1 parent 15d2e56 commit 46c3f84

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

packages/flutter/test/material/segmented_button_test.dart

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1514,6 +1514,24 @@ void main() {
15141514
SystemMouseCursors.grab,
15151515
);
15161516
});
1517+
1518+
testWidgets('SegmentedButton does not crash at zero area', (WidgetTester tester) async {
1519+
await tester.pumpWidget(
1520+
MaterialApp(
1521+
home: Center(
1522+
child: SizedBox.shrink(
1523+
child: SegmentedButton<String>(
1524+
segments: const <ButtonSegment<String>>[
1525+
ButtonSegment<String>(value: 'X', label: Text('X')),
1526+
],
1527+
selected: const <String>{'X'},
1528+
),
1529+
),
1530+
),
1531+
),
1532+
);
1533+
expect(tester.getSize(find.byType(SegmentedButton<String>)), Size.zero);
1534+
});
15171535
}
15181536

15191537
Set<WidgetState> enabled = const <WidgetState>{};

0 commit comments

Comments
 (0)