-
Notifications
You must be signed in to change notification settings - Fork 129
Description
There's been discussion on #1253 and elsewhere that some users would prefer some argument lists to split even when they would fit within a single line. I'm open to the idea, but I don't know what heuristics would work best. A very simple one (at least as I understand it) suggested by @koji-1009 is: Always split argument lists with named arguments.
This has a couple of nice properties:
- My intuition is that users generally expect positional argument lists to be dense and single line when possible.
- Flutter code, which is almost more like "markup" than "code" seems to be where users want argument lists to split even when they don't have to. And those constructor calls tend to mostly use named arguments.
On the other hand, I'm sure there are function calls with named arguments that aren't inside Flutter build code and which would look pretty bad if forcibly split. Off the top of my head, I can't see anyone preferring:
Duration(
minutes: 1,
);Over:
Duration(minutes: 1);There is a rule in the formatter for collection literals that says a collection literal will always split if it contains any nested ones. That gives you:
[
[1],
]Instead of:
[[1]]Perhaps a similar rule for argument lists would help here. We could consider always splitting an argument list if it has named arguments and at least one of those arguments is also a function call. However note that that rule would not work for the actual example brought up by @koji-1009:
EdgeInsets.only(
top: 10.0,
right: 20.0,
)(Personally, if this were my code, I would prefer that call to not be split if possible.)