VSCode
mac上快捷键 command+P进入 settings.json
在里面添加如下代码, 里面的 “dart.flutterSdkPath”: “/Users/xxx/Library/flutter”,改为自己的flutter 路径
{
"editor.fontSize": 14,
"[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": "off",
"editor.bracketPairColorization.enabled": true
},
"editor.formatOnSave": true,
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": true
},
"dart.debugExternalPackageLibraries": true,
"dart.debugSdkLibraries": false,
"editor.stickyScroll.enabled": true,
"dart.previewFlutterUiGuides": true,
"files.autoSave": "onFocusChange",
"jsonToDart.nullSafety": true,
"dart.dartTestLogFile": null,
"dart.flutterSdkPath": "/Users/xxx/Library/flutter",
"dart.flutterDaemonLogFile": null,
"workbench.iconTheme": "material-icon-theme",
"dart.analyzerInstrumentationLogFile": null,
"window.zoomLevel": 1,
"window.openFoldersInNewWindow": "on"
}
在编写代码时
1 保存或退出类代码自动格式化
2 自动补全const,
3 代码不规范会给警告,如过多判空,代码会自动纠正
4保存自动去除无效导入
5 代码字体大小 14,最长80换行,这个可以自己调整