-
Notifications
You must be signed in to change notification settings - Fork 170
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
proposal: move_color_to_decoration
#3063
Comments
/fyi @Hixie @goderbauer @HansMuller |
This seems useful to inform people of an illegal configuration at code write time instead of compile time. |
I agree, if we can flag this problem early it's a win for developers. |
This is terrific and addresses a problem that really trips folks up. I looked at this a while ago and recall there are at least a handful of other Flutter classes w/ similar constraints. Doing a quick scan now I see similar patterns in at least: Using an annotation, for example, we could capture this constraint at the API level.
EDIT: removed annotation proposal in favor of centralizing that discussion in dart-lang/sdk#47712 /fyi @bwilkerson @InMatrix @leafpetersen @munificent who were in on the original conversation about annotating exclusive params vs. a language solution like overloading. /fyi also @natebosch @jakemac53 @lrhn @eernstg for more language team perspective |
In terms of using an annotation for this, I think the right next step is to create a new issue (in the sdk repo) to discuss the kinds of information we'd need to capture for the use cases we know about, and then the right set of annotations with which to capture that information. It might well be that |
@bwilkerson, agreed. I created dart-lang/sdk#47712 and updated my proposal above to link out to it. |
move_color_to_decoration
Description
Don't provide
Container
with both non-nullcolor
anddecoration
. Placecolor
insidedecoration
instead.Details
When a
Container
is provided with bothcolor
anddecoration
(both non-null), an error is thrown at runtime, and there is currently nothing that warns you about that beforehand. This rule prevents you from running into the error by prompting to movecolor
intodecoration
.Kind
Guard against errors.
Good Examples
Bad Examples
Discussion
Those who already ran into the error will know, but those who haven't will certainly do, and that's simply annoying. No one wants to dig through unexpected error messages, even if this one is rather easy to identify.
Discussion checklist
Slightly complementing: proposal:
use_decorated_box
#3060use_decorated_box
#3061Not found.
None.
The text was updated successfully, but these errors were encountered: