-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Make sure that a DropdownButton doesn't crash in 0x0 environment #174880
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 DropdownButton doesn't crash in 0x0 environment #174880
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 DropdownButton doesn't crash when rendered in a zero-sized area. The test correctly sets up the scenario using a SizedBox.shrink(). My review includes a suggestion to make the test more comprehensive by also triggering the dropdown menu to open, which was the source of the original crash. This ensures the fix is fully covered.
dkwingsmt
left a comment
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.
Checklist:
- The test is in the correct file
- The test name goes “does not crash at zero area”
- The target widget is wrapped by
Center(or is fullscreen) - The target widget is not a overlay
- Expect the target widget has a size of exactly
Size.zero
| ), | ||
| ), | ||
| ); | ||
| expect(tester.getSize(find.byType(DropdownButton<String>)), 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.
It would be convenient to test that the DropdownMenuItem has a zero size, but the test fails with a size of (16.1, 0.0).
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.
It's fine and expected. We've encountered many cases where the children of zero-sized parents have non-zero sizes. We should only test the target widget alone. DropdownMenuItem can have its own test in a similar fashion.
2644a07 to
17d90cf
Compare
dkwingsmt
left a comment
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.
LGTM, thank you!
dcd769e to
70a5d35
Compare
3155278 to
a135ba2
Compare
|
Analyze error: error • The named parameter 'items' is required, but there's no corresponding argument • packages/flutter/test/material/dropdown_test.dart:4707:43 • missing_required_argument
error • The named parameter 'onChanged' is required, but there's no corresponding argument • packages/flutter/test/material/dropdown_test.dart:4707:43 • missing_required_argument |
flutter/flutter@891d7d5...2d34167 2025-10-20 [email protected] Cleanup create_updated_flutter_deps.py a bit (flutter/flutter#177162) 2025-10-20 [email protected] Fixed hot reload/restart crashes after closing browser tab on web-server device (flutter/flutter#177026) 2025-10-20 [email protected] Roll Skia from 0a3ace6fde82 to ed4294faecde (2 revisions) (flutter/flutter#177249) 2025-10-20 [email protected] Add DropdownMenu.decorationBuilder (flutter/flutter#176264) 2025-10-20 [email protected] Roll Skia from 05e2f42f533d to 0a3ace6fde82 (1 revision) (flutter/flutter#177242) 2025-10-20 [email protected] Roll Skia from 89abc5393317 to 05e2f42f533d (1 revision) (flutter/flutter#177238) 2025-10-20 [email protected] [ios][engine] Fix autofill context cleanup and view lifecycle management (flutter/flutter#173598) 2025-10-20 [email protected] Fix Image.network not using cache when headers are specified (flutter/flutter#176831) 2025-10-19 [email protected] Roll Dart SDK from a66f334fee2a to 2cd2106f2cef (4 revisions) (flutter/flutter#177190) 2025-10-19 [email protected] Roll Skia from 2d424175a481 to 89abc5393317 (1 revision) (flutter/flutter#177235) 2025-10-19 [email protected] Make sure that a ListTile doesn't crash in 0x0 environment (flutter/flutter#176176) 2025-10-19 [email protected] Make sure that a DropdownButton doesn't crash in 0x0 environment (flutter/flutter#174880) 2025-10-19 [email protected] Roll Skia from 899155871d29 to 2d424175a481 (1 revision) (flutter/flutter#177229) 2025-10-19 [email protected] Roll Skia from b864c56efb66 to 899155871d29 (1 revision) (flutter/flutter#177227) 2025-10-19 [email protected] Roll Fuchsia Linux SDK from M8WT2GMY46e_0fFho... to tKrvmvTOQITL81oOC... (flutter/flutter#177223) 2025-10-19 [email protected] Roll Skia from 0992b560454f to b864c56efb66 (1 revision) (flutter/flutter#177222) 2025-10-18 [email protected] Fix HEIF decoding (flutter/flutter#176860) 2025-10-18 [email protected] Roll Skia from 74df18176924 to 0992b560454f (1 revision) (flutter/flutter#177217) If this roll has caused a breakage, revert this CL and stop the roller using the controls here: https://autoroll.skia.org/r/flutter-packages Please CC [email protected],[email protected] on the revert to ensure that a human is aware of the problem. To file a bug in Packages: https://github.com/flutter/flutter/issues/new/choose To report a problem with the AutoRoller itself, please file a bug: https://issues.skia.org/issues/new?component=1389291&template=1850622 Documentation for the AutoRoller is here: https://skia.googlesource.com/buildbot/+doc/main/autoroll/README.md
…tter#174880) This is my attempt to handle flutter#6537 for the DropdownButton widget. --------- Co-authored-by: Tong Mu <[email protected]>
This is my attempt to handle #6537 for the DropdownButton widget.