From ef158c39a3315a8ba3113e4e33e6f40fd6ab3370 Mon Sep 17 00:00:00 2001 From: Ahmed Mohamed Sameh Date: Fri, 10 Oct 2025 08:42:24 +0300 Subject: [PATCH] Make sure that an InputChip doesn't crash in 0x0 environment (#175930) This is my attempt to handle https://github.com/flutter/flutter/issues/6537 for the InputChip widget. --------- Co-authored-by: Tong Mu --- .../test/material/input_chip_test.dart | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/packages/flutter/test/material/input_chip_test.dart b/packages/flutter/test/material/input_chip_test.dart index 40d68c0b681..e07942b63a4 100644 --- a/packages/flutter/test/material/input_chip_test.dart +++ b/packages/flutter/test/material/input_chip_test.dart @@ -688,4 +688,26 @@ void main() { SystemMouseCursors.forbidden, ); }); + + testWidgets('InputChip does not crash at zero area', (WidgetTester tester) async { + Future testChip(Widget chip) async { + await tester.pumpWidget( + MaterialApp( + home: Scaffold( + body: Center(child: SizedBox.shrink(child: chip)), + ), + ), + ); + expect(tester.getSize(find.byType(InputChip)), Size.zero); + } + + await testChip(const InputChip(label: Text('X'))); + await testChip( + const InputChip( + label: Text('X'), + avatar: CircleAvatar(child: Text('A')), + ), + ); + await testChip(InputChip(label: const Text('X'), onDeleted: () {})); + }); }