I've been trying different configurations in the code-formatting settings from Android-Studio, but the results have been pretty disappointing (and triggering) so far.
This is what the reformat code
does without the dartfmt
tool (notice line 94 - 110):
dartfmt
does a better job of it, but the indentation is horrible (line 91 - 96) and very inconsistent with seemingly no settings to configure for it:
This is what I would want it to look like:
What settings do I need to change to achieve this? It's currently pretty hard to read the code.
You can't configure dartfmt
. This is voluntary. But dartfmt
uses trailing comma as it's core to determine where to go to newline.
The following :
foo({String foo, String bar}) {}
void main() {
foo(foo: "Hello", bar: "Hello");
}
will stay unchanged when running dartfmt
.
But simply changing to foo
call to :
...bar: "Hello",);
will reformat it to :
foo({String foo, String bar}) {}
void main() {
foo(
foo: "Hello",
bar: "Hello",
);
}
It is too late but it can help.
In Android Studio go to
File > Settings > Editor > Code Style > Dart
and increase the value of Line Length.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With