A clean, productivity-focused VS Code configuration for Flutter and Dart development. Drop these files into your project and get formatting, auto-imports, const fixes, and more — all on save.
📖 For a full walkthrough of each setting, check out the companion article: A Clean & Productive VS Code Setup for Flutter & Dart Developers
| File | Purpose |
|---|---|
.vscode/settings.json |
Editor formatting, save actions, Dart/Flutter quality-of-life settings |
analysis_options.yaml |
Lint rules that power auto-const fixes on save |
- Copy
.vscode/settings.jsoninto your project's.vscode/folder. - Copy
analysis_options.yamlinto your project root. - Make sure
flutter_lintsis in yourpubspec.yaml:
dev_dependencies:
flutter_lints: ^5.0.0- Run
flutter pub get, then open any Dart file and hit Cmd+S (or Ctrl+S).
- Code is formatted using
dart format - Imports are sorted and unused ones are removed
- Missing imports are added automatically
constkeywords are added wherever possible- Trailing whitespace is trimmed
Keeps code clean without any manual effort.
"editor.codeActionsOnSave": {
"source.organizeImports": "always",
"source.addMissingImports": "always",
"source.fixAll": "always"
}source.fixAll: "always" is the key setting — it applies all auto-fixable lint warnings on save, including adding const. This only works if the corresponding lint rules are active in analysis_options.yaml.
"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": trueNo more trailing spaces or inconsistent file endings in your diffs.
"dart.hotReloadOnSave": "all"Triggers Flutter hot reload automatically whenever you save a file.
"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": true,
"editor.stickyScroll.enabled": trueMakes deeply nested widget trees much easier to navigate.
These four rules are what make auto-const work on save:
| Rule | What it does |
|---|---|
prefer_const_constructors |
Adds const to constructors that can be constant |
prefer_const_literals_to_create_immutables |
Makes [] → const [] inside immutable widgets |
prefer_const_declarations |
Changes final x = 5 → const x = 5 where possible |
prefer_const_constructors_in_immutables |
Enforces const constructors on StatelessWidget subclasses |
Without these rules active, source.fixAll has nothing to fix — so both files are needed together.
- Dart-Code extension
- Flutter extension
- Flutter SDK
flutter_lintsindev_dependencies