I am developing with Flutter using Android Studio. When I try to format the code using the Cmd + Opt + L keys, it ends up like #1 below.
Is there a good way to make it look like #2?
//#1
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
children: [
const Text("signup page"),
ElevatedButton(
onPressed: () {
debugPrint("");
},
child: const Text(""))
],
)));
}
//#2
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: Column(
children: [
const Text("signup page"),
ElevatedButton(
onPressed: () {
debugPrint("");
},
child: const Text("")
)
],
)
)
);
}
I tried using analysis_options.yaml and .editorconfig, but I couldn’t find an option to configure it the way I want.
Is there anything I might have missed?
2
Answers
this is the first kind with dart autoformatting
but the same code can be arranged as
how can this be done?
simply add a
comma
at the end of line.To formate the code you have to add commas
,
commas make the code take the line for itself,like this:
Hope that helps.