Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make Dart files break one line per parameter in VsCode?

I am learning Flutter/Dart, and in the video series I am following, there is only one parameter per line, as follows:

body: Container(
        width: double.infinity,
        height: double.infinity,
        child: Row(
          mainAxisAlignment: MainAxisAlignment.center, 
          children: [
            Text('Counter ${counter}'),
            CustomSwitch(),
          ]),
      )

but in my editor, the line won’t break per parameter.

Since I am using Dart Recommended Settings, I thought it would be the same here in my editor, but what happens is the following:

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

body: Container(
        width: double.infinity,
        height: double.infinity,
        child: Row(mainAxisAlignment: MainAxisAlignment.center, children: [
          Text('Counter ${counter}'),
          CustomSwitch(),
        ]),

See how the ‘child’ property has both mainAxisAliment and children in the same line?

How do I setup my settings, so that doesn’t happen, and one parameter is shown per line?

I thought I could just reduce the line width (currently 80, as suggested), but that wouldn’t break exactly one parameter per line.

>Solution :

Adding coma,whenever possible will provide your desire result. In your case, you can add another coma after ],. This will format the code.

 CustomSwitch(),
    ],
  ),
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading