-
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
Better code formatting for flow controls in Maps #1440
Comments
Maybe the issue should be moved to: https://github.com/dart-lang/dart_style/issues ? |
Oh definitely, I didn't know that there is a separate repository for the formatted. So please anyone who can move an issue please move it there? |
I agree! final current = {
if (true) 'a': 1,
for (final i in [1, 2, 3]) 'b$i': i,
for (final nested in foo1)
for (final i in nested) 'c$i': i,
for (final nested in foo2) ...nested,
}; final proposed = {
if (true)
'a': 1,
for (var i in [1, 2, 3])
'b$i': i,
for (final nested in foo1)
for (final i in nested)
'c$i': i,
for (final nested in foo2)
...nested,
}; |
munificent
changed the title
[dartformat] Better code formatting for flow controls in Maps
Better code formatting for flow controls in Maps
Aug 3, 2024
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I recently stumbled upon this piece of code from a colleague of mine and had real problems at first to understand what is going on here:
One reason for sure was that I wasn't aware that we can use
if
andfor
not only insideLists
but also forMaps
which is indeed a pretty cool feature :-) the bigger reason IMHO is that the way dartformat currently treats this makes it hard to spot where the key of the created/inserted pair is. To be honest I don't have a good idea of how to do this better. Maybe outdent the key?Maybe @munificent has an idea of how to improve this.
The text was updated successfully, but these errors were encountered: