-
Notifications
You must be signed in to change notification settings - Fork 29.5k
Make sure that a TextButton doesn't crash in 0x0 environment #178213
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make sure that a TextButton doesn't crash in 0x0 environment #178213
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Code Review
This pull request adds a regression test to ensure that TextButton does not crash when placed in a zero-sized container. The test correctly reproduces the scenario by placing a TextButton inside a SizedBox.shrink() and verifies that no crash occurs during widget pumping. My feedback includes a suggestion to consider relocating the test to a more appropriate test suite for better code organization.
| testWidgets('TextButton does not crash at zero area', (WidgetTester tester) async { | ||
| await tester.pumpWidget( | ||
| MaterialApp( | ||
| home: Center( | ||
| child: SizedBox.shrink( | ||
| child: TextButton(onPressed: () {}, child: const Text('X')), | ||
| ), | ||
| ), | ||
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(TextButton)), Size.zero); | ||
| }); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a good regression test for the issue. However, this test appears to be for a core behavior of the TextButton widget itself, while other tests in this file are specific to the TextButtonUseCase. To improve code organization and discoverability for future developers, please consider moving this test to the main test file for TextButton, which is likely packages/flutter/test/material/text_button_test.dart.
f5fe037 to
4db66c9
Compare
This is my attempt to handle #6537 for the TextButton widget.