-
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
Can indentation of multiline arrow functions be 2 instead of 4? #809
Comments
Formatting of expression functions should be improved by #794 |
@a14n Is that PR effective in the latest flutter? I can't get the wanted result. |
Can you paste the resulting code here? |
Same as OP.
|
The above PR doesn't handle expression function body. |
The repro case is as simple as
|
bump, very annoying |
I think the forthcoming tall style handles this more or less how I expect, though it isn't exactly what's requested. When it can, it avoids splitting after class MyApp extends StatelessWidget {
Widget buildRow() => Row(children: [
Image.asset('images/pic1.jpg'),
Image.asset('images/pic2.jpg'),
Image.asset('images/pic3.jpg'),
]);
} That seems to be what most users prefer based on comments on other issues and looking at the Flutter repo's hand formatting. But it does still sometimes decide to split after the class MyApp extends StatelessWidget {
Widget buildRow() =>
Row(mainAxisAlignment: MainAxisAlignment.spaceEvenly, children: [
Image.asset('images/pic1.jpg'),
Image.asset('images/pic2.jpg'),
Image.asset('images/pic3.jpg'),
]);
} It might be better to prefer: class MyApp extends StatelessWidget {
Widget buildRow() => Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
Image.asset('images/pic1.jpg'),
Image.asset('images/pic2.jpg'),
Image.asset('images/pic3.jpg'),
],
);
} But that's a separate style choice around how whether splitting an argument list in certain ways should take priority over splitting the surrounding construct (in this case Since this issue is about the indentation and the new style is working as I expect, I'm going to go ahead and close this one. |
The indentation of multiline arrow functions is now 4. For example:
This example is from a flutter example. I personally avoid arrow functions like above for my flutter code at this moment. The reason is purely aesthetic. The indentation seems too much and therefore it also doesn't align well with block body functions.
If it would be indented 2 it would look like this:
If multiline arrow function could also start on the next line, it would be the most pleasing to the eyes in my opinion:
Using a comment forces dart_fmt to align the expression on the next line, but I would love if this is automatic.
The main reason I start this issue, is because I believe in having as little noise as possible in our flutter UI code. Arrow functions like in this last example, have very little noise, and look very symmetric and aesthetically pleasing.
The text was updated successfully, but these errors were encountered: