.gitignore for Dart
14 ignore rules for Dart, ready to copy into your repository.
Client-optimized language by Google
The complete .gitignore for Dart
# Generated by LFGitignore - https://lfgitignore.com
# Created: 2026-08-05 01:31:13 UTC
# Technologies: Dart
### Dart ###
.dart_tool/
.packages
# Build output directory
build/
pubspec.lock
doc/api/
.env*
*.dart.js
*.info.json
*.js
*.js_
*.js.deps
*.js.map
.flutter-plugins
.flutter-plugins-dependencies
What these Dart rules actually ignore
Every pattern below, and why it belongs in your .gitignore.
Files and directories created by pub
| Pattern | What it ignores |
|---|---|
.dart_tool/ |
Files and directories created by pub |
.packages |
Files and directories created by pub |
build/ |
Build output directory |
If you're building an application, you may want to check-in your pubspec.lock
| Pattern | What it ignores |
|---|---|
pubspec.lock |
If you're building an application, you may want to check-in your pubspec.lock |
If you don't generate documentation locally you can remove this line.
| Pattern | What it ignores |
|---|---|
doc/api/ |
If you don't generate documentation locally you can remove this line. |
.env* |
dotenv environment variables file |
Avoid committing generated Javascript files:
| Pattern | What it ignores |
|---|---|
*.dart.js |
Avoid committing generated Javascript files: |
Produced by the --dump-info flag.
| Pattern | What it ignores |
|---|---|
*.info.json |
Produced by the --dump-info flag. |
*.js |
When generated by dart2js. Don't specify *.js if your project includes source files written in JavaScript. |
*.js_ |
Produced by the --dump-info flag. |
*.js.deps |
Produced by the --dump-info flag. |
*.js.map |
Produced by the --dump-info flag. |
.flutter-plugins |
Produced by the --dump-info flag. |
.flutter-plugins-dependencies |
Produced by the --dump-info flag. |
How to use this .gitignore for Dart
- Copy the Dart rules above, or download the file directly.
- Create a file named .gitignore at the root of your Git repository and paste the rules into it.
- If some of those files are already tracked, run git rm -r --cached . then commit again — Git only applies ignore rules to untracked files.
- Commit the .gitignore so everyone on the team shares the same rules.