-
Notifications
You must be signed in to change notification settings - Fork 120
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
Tall style: single argument => with multiple .. is very tall #1603
Comments
This is essentially the same issue as #1466. ( I agree, it doesn't look great. I haven't been able to come up with a fix that doesn't do the wrong thing in some cases. Here, if the cascade target expression was longer than just I have some ideas on how to fix this, #1466, and #1465, but I haven't been able to get them working with decent performance yet. It's a surprisingly hard problem. One option might be to do a hacky fix where we don't split after the |
Thanks :) Yes, I can see how piling up hacky fixes could lead to problems ;) |
For what it's worth, for final value = Value((b) {
b
..anInt = 3
..aString = 'four';
}); But the single final value = Value((builder) {
builder
..anInt = 3
..aString = 'four';
}); I assume we cannot get this in tall style: final value = Value((b) => b
..anInt = 3
..aString = 'four'); so with a formatter tweak the best we could get is probably: final value = Value(
(b) => b
..anInt = 3
..aString = 'four'
); This uses the same vertical space and indentation as the |
I don't think
whereas the block never will:
so the arrow is obviously preferred ... if people start using the block for >= 2 assignments, you'd have to convert between the two when adding/removing an assignment :/ |
FWIW, I also don't like renaming b->builder, I've seen a few codebases that did that and it wasn't convincing :) ... as it doesn't really add anything. In fact it would be great if there was a way in the language to not mention it at all:
|
Short style:
Tall style:
Any ideas please? :)
I'd be open to pushing for a new special case syntax for "lambda that immediately does something to its only argument and never references it again" if that's what it takes ;)
The text was updated successfully, but these errors were encountered: