-
Notifications
You must be signed in to change notification settings - Fork 121
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
Formatting call chain is a bit off #989
Comments
@long1eu This behavior is actually by design if you read their FAQ. However, I have to agree with you that the output is confusing when coming from other formatters such as Prettier for JS/TS or dotnet format. It would be nice to have an option to indent relative to the surrounding expression. At the end of the day, it might just be something we have to adjust to since configuration options are not a goal of this project (#534). Give this issue a +1 if you'd like to see an alternative formatter: Dart-Code/Dart-Code#914 |
Yeah, the formatter's heuristics around when to do "block-like" formatting for nested function expressions and collection literals currently lean pretty hard towards block style. That's good for some things like tests: test('blah', () {
// Potentially lots of code here.
}); But it doesn't look great in some cases, like your example here. This is a difficult part of the formatter to change because it impacts so much existing formatted code and it tends to make some cases better and others worse. Users don't like it when any existing formatted code gets uglier. At some point, though, it may be worth revisiting this. |
The forthcoming tall style does the right thing. It gives you: _firestore //
.doc('$_usersCollection/$uid/streams/$streamId')
.update(<String, dynamic>{
'relocationOffered': relocation,
'workSituation': workSituation,
'zipCode': zipCode,
}); And: _firestore //
.doc('$_usersCollection/$uid/streams/$streamId')
.update(<String, dynamic>{
'relocationOffered': relocation,
'workSituation': workSituation,
'zipCode': zipCode,
})
.then((value) => null); |
Hi!
I really love dartfmt in general but there is this issue that bugs my head.
Why does the following piece of code format like this:
and not like this:
Sure it looks even worse if I do this:
But looks perfect if I do this:
But of course I can live with something like this:
The text was updated successfully, but these errors were encountered: