VSCode offers many ways to make coding faster and easier. You can set it up to do things like automatically format your code when you save a file. Here are some helpful settings that can really save you time when working, especially with Flutter.
Why These Settings Help
Coding involves lots of small tasks, like making sure your code looks neat (formatting) or fixing simple errors. Doing these manually takes time. By automating them, you can focus more on building cool features.
Key VSCode Settings
These settings go into your VSCode settings.json
file. You can open it by pressing Ctrl+,
(or Cmd+,
on Mac) and searching for "settings json".
General Formatting
"editor.formatOnSave": true
This setting means VSCode will try to format your file every time you save it. This keeps your code looking consistent automatically.
Dart Specific Settings
Sometimes, you want slightly different behavior for specific languages like Dart. You can set language-specific rules inside the [dart]
section.
Dart Formatting on Save
"editor.formatOnSave": false
Inside the [dart]
block, setting formatOnSave
to false
overrides the global setting for Dart files. This might be used if you prefer formatting Dart using other methods or specific save actions.
Turning Off Inlay Hints
"editor.inlayHints.enabled": "off"
Inlay hints show extra information right in your code, like variable types in grey text. Turning them "off" makes the code view less cluttered, which some developers prefer.
Save Actions for Dart
"editor.codeActionsOnSave": {
"source.fixAll": "explicit",
"source.organizeImports": "explicit"
}
This tells VSCode to run specific actions when you save a Dart file. The "explicit"
value means these actions run when you explicitly save the file (like pressing Ctrl+S
/Cmd+S
).
Fix All Issues
"source.fixAll": "explicit"
This action automatically applies suggested fixes for various issues in your code when you save. This can include adding missing const
keywords or fixing other small warnings.
Organize Imports
"source.organizeImports": "explicit"
This action automatically sorts your import statements and removes any imports that aren't being used in your file when you save.
By setting up these configurations, you can let VSCode handle repetitive tasks, giving you more time to code!