Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VS Code removes trailing commas when saving dart files for new projects

I created a new project and VS Code condenses any trailing commas unless line lengths are very long. This is a new behaviour. Have looked all over the internet, reinstalled, deleted cache files etc. No differences in any settings file at the user or workspace level. Both same versions of flutter and dart. Both same extensions (only flutter and dart). No difference in analyzer file... so I'm completely lost. Is this a new VS Code thing? It is very annoying as I'm trying to work on UI layouts and save condenses things to one line.

like image 701
nktokyo Avatar asked Mar 03 '26 04:03

nktokyo


1 Answers

Add the following to analysis_options.yaml in the Flutter project.

formatter:
  trailing_commas: preserve
like image 147
pypypmi Avatar answered Mar 05 '26 23:03

pypypmi



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!