-
Notifications
You must be signed in to change notification settings - Fork 29.8k
Improve Container color/decoration error message clarity #178823
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
Improve Container color/decoration error message clarity #178823
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 improves the clarity of an error message in the Container widget. The assertion message for when both color and decoration are provided has been rewritten to be more explanatory and less confusing. A corresponding test case has been added to verify that the new, clearer error message is thrown as expected. The changes are correct and improve the developer experience.
The previous assertion message was confusing because it stated 'Cannot provide both' but then suggested 'To provide both, use...', which contradicted the restriction. This confused developers about the actual requirement. Updated the message to clearly explain: - The color parameter is a shorthand for decoration: BoxDecoration(color: color) - Developers should use either color OR decoration, not both - To use both color and other decoration properties, set the color within BoxDecoration Fixes flutter#119484
d420480 to
db3b47e
Compare
|
It looks like this pull request may not have tests. Please make sure to add tests or get an explicit test exemption before merging. If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. If you believe this PR qualifies for a test exemption, contact "@test-exemption-reviewer" in the #hackers channel in Discord (don't just cc them here, they won't see it!). The test exemption team is a small volunteer group, so all reviewers should feel empowered to ask for tests, without delegating that responsibility entirely to the test exemption group. |
justinmc
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 👍 . Thanks for improving this! From the issue it looks like indeed this was tripping people up.
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.
Great writeup. Thanks!
Description
This PR improves the clarity of the error message shown when developers provide both
coloranddecorationparameters to aContainerwidget.Problem
The previous assertion message was confusing and contradictory:
This message stated "Cannot provide both" but then suggested "To provide both, use...", which confused developers about the actual requirement. The suggestion appeared to offer a workaround to use both parameters together, when in fact it was explaining how to migrate from using
colorto usingdecorationexclusively.Solution
Updated the assertion message to clearly explain:
colorparameter is a shorthand fordecoration: BoxDecoration(color: color)colorORdecoration, not bothBoxDecorationinsteadNew message:
Related Issues
Fixes #119484
Pre-launch Checklist
///).