简体   繁体   English

vsCode中的Formatting.dart文件(flutter)

[英]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.我有 Dart 和 Flutter vsCode 扩展。

Here is my settings.json file:这是我的 settings.json 文件:

{
  "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?有什么我想念的吗?

"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 .格式化是由 Dart 扩展完成的(因为它不是 Flutter 特有的),所以应该设置为Dart-Code.dart-code而不是Dart-Code.flutter

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM