dart-lang / dart_style

An opinionated formatter/linter for Dart code
https://pub.dev/packages/dart_style
BSD 3-Clause "New" or "Revised" License
645 stars 118 forks source link

Block-format await expressions if the inner expression allows it. #1538

Closed munificent closed 4 weeks ago

munificent commented 1 month ago

In assignment-like context, if the RHS is an await expression and the inner expression can be block formatted, then let the whole await expression be block formatted.

This comes into play in assignments, but not in argument lists which are the other place where block formatting is a thing. That's because in argument lists, we don't treat function calls as block formattable. (This is both for performance and style reasons). There's no point in awaiting any of the other kinds of block-formattable expressions: collection literals or function expressions.

So this really just benefits assignments, named argument expressions, and => bodies. But it definitely makes those look better.

Fix #1531.