Skip to content

aydozy/flutter-vscode-settings

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 

Repository files navigation

Flutter & Dart — VS Code Setup

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


What's included

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

Quick start

  1. Copy .vscode/settings.json into your project's .vscode/ folder.
  2. Copy analysis_options.yaml into your project root.
  3. Make sure flutter_lints is in your pubspec.yaml:
dev_dependencies:
  flutter_lints: ^5.0.0
  1. Run flutter pub get, then open any Dart file and hit Cmd+S (or Ctrl+S).

What happens on save

  • Code is formatted using dart format
  • Imports are sorted and unused ones are removed
  • Missing imports are added automatically
  • const keywords are added wherever possible
  • Trailing whitespace is trimmed

settings.json — highlights

Formatting

"editor.formatOnSave": true,
"editor.formatOnType": true,
"editor.formatOnPaste": true

Keeps code clean without any manual effort.

Save actions

"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.

File cleanliness

"files.trimTrailingWhitespace": true,
"files.insertFinalNewline": true,
"files.trimFinalNewlines": true

No more trailing spaces or inconsistent file endings in your diffs.

Hot reload on save

"dart.hotReloadOnSave": "all"

Triggers Flutter hot reload automatically whenever you save a file.

Editor readability

"editor.bracketPairColorization.enabled": true,
"editor.guides.bracketPairs": true,
"editor.stickyScroll.enabled": true

Makes deeply nested widget trees much easier to navigate.


analysis_options.yaml — const rules

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 = 5const 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.


Requirements

About

A clean VS Code setup for Flutter & Dart developers. Drop in and code.

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors