Home > Net >  Why does formatting code in VS Code always return uglier code than I expected?
Why does formatting code in VS Code always return uglier code than I expected?

Time:11-20

I'm formatting code in VS Code. However, VS Code always returns uglier code than I expected.

Example:

My original code:

                                                    body: Padding(
                                                      padding: const EdgeInsets.all(AppSizes.kDefaultPadding,),
                                                      …
                                                    ),

Expected code:

                                                    body: Padding(
                                                      padding: const EdgeInsets.all(
                                                        AppSizes.kDefaultPadding,
                                                      ),
                                                      …
                                                    ),

Actual code:

                                                    body: Padding(
                                                      padding:
                                                          const EdgeInsets.all(
                                                        AppSizes
                                                            .kDefaultPadding,
                                                      ),
                                                      …
                                                    ),

The actual code is really ugly (in my opinion, not sure how others see it).

How can I get the expected code? I would appreciate any help. Thank you in advance!

CodePudding user response:

As jamesdlin commented, Open your setting and search for dart line length, increase the value

enter image description here

enter image description here

  • Related