-
Notifications
You must be signed in to change notification settings - Fork 122
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
=>
closures formatting in named argument list
#1545
Comments
The same happens in #1525 although it is not a named argument case but a cascade case. |
I hadn't found this issue before I opened #1634. I agree, seems like a surprising downgrade when we combine a named argument, a shorthand ( Copying my examples from that issue: Old formatter: Widget example1() {
return ValueListenableBuilder(
valueListenable: userInfoSource,
builder: (context, userInfo, _) => ListBody(
children: [
Text('Hello ${userInfo.name}'),
Text('Your email is ${userInfo.email}'),
],
),
);
}
Widget example2() {
return LayoutBuilder(
builder: (context, constraints) => SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: constraints.maxHeight),
child: PotentiallyTallWidget(),
),
),
);
} New formatter: Widget example1() {
return ValueListenableBuilder(
valueListenable: userInfoSource,
builder:
(context, userInfo, _) => ListBody(
children: [
Text('Hello ${userInfo.name}'),
Text('Your email is ${userInfo.email}'),
],
),
);
}
Widget example2() {
return LayoutBuilder(
builder:
(context, constraints) => SingleChildScrollView(
child: ConstrainedBox(
constraints: BoxConstraints(minHeight: constraints.maxHeight),
child: PotentiallyTallWidget(),
),
),
);
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
The new dart formatter wants to format this as follows:
This gives the closure a lot of prominence over the other parameters and also causes more indentation reducing the effective line length for code inside the closure.
This formatting would visually also be more in line with the formatting I'd expect if builder were a list argument:
@munificent did mention that there are cases were this kind of formatting for
=>
closures looks worse. I'm interested in seeing examples for that.The text was updated successfully, but these errors were encountered: