Marko Marchisio
Marko Marchisio

Reputation: 497

Formatting .dart files (flutter) in vsCode

I can't seem to set the automatic formatter up.

I have both the Dart and Flutter vsCode extensions.

Here is my settings.json file:

{
  "workbench.iconTheme": "material-icon-theme",
  "terminal.integrated.shell.windows": "C:\\Program Files\\Git\\bin\\bash.exe",
  "debug.openDebug": "openOnDebugBreak",

  "[javascript]": {
    "editor.defaultFormatter": "esbenp.prettier-vscode",
    "editor.formatOnSave": true
  },

  "explorer.confirmDelete": false,
  "javascript.updateImportsOnFileMove.enabled": "always",
  "typescript.updateImportsOnFileMove.enabled": "always",

  "[dart]": {
        "editor.formatOnSave": true,
        "editor.formatOnType": true,
        "editor.rulers": [80],
        "editor.selectionHighlight": false,
        "editor.suggest.snippetsPreventQuickSuggestions": false,
        "editor.suggestSelection": "first",
        "editor.tabCompletion": "onlySnippets",
        "editor.wordBasedSuggestions": false,
    "editor.defaultFormatter": "Dart-Code.flutter",
    },
  
  "dart.flutterHotReloadOnSave": "always",
  "editor.defaultFormatter": "Dart-Code.dart-code",
  "editor.formatOnSave": true,
}

I want the formatter to add ; and , at the end of lines and also to add/remove spacing and indenting where needed. Is there anything I'm missing?

Upvotes: 3

Views: 4474

Answers (1)

Danny Tuppeny
Danny Tuppeny

Reputation: 42343

"editor.defaultFormatter": "Dart-Code.flutter",

Formatting is done by the Dart extension (since it's not specific to Flutter), so this should be set to Dart-Code.dart-code rather than Dart-Code.flutter.

Upvotes: 5

Related Questions