Skip to content
Aqib Javed.
All guides

Developer guide · Windows and Mac

How to clear the Flutter cache: build output, pub cache and SDK cache

By Aqib Javed · Updated Nov 27, 2026

Run flutter clean in the project folder: it deletes build/, .dart_tool/ and Flutter's generated platform files, and flutter pub get brings back what the project needs. The package cache shared by all projects is separate: dart pub cache clean empties ~/.pub-cache (%LOCALAPPDATA%\Pub\Cache on Windows), and dart pub cache repair downloads packages again. If the Flutter tool itself is broken, delete the SDK's bin/cache folder and Flutter downloads it again. Stackyard, free, clears build folders in projects you haven't touched in months.

What flutter clean deletes

  • build/, where every platform's build output goes, Android's included.
  • .dart_tool/, with the package config and build caches pub and the Dart tools keep for the project.
  • The generated ephemeral folders: ios/Flutter/ephemeral, macos/Flutter/ephemeral, linux/flutter/ephemeral and windows/flutter/ephemeral, plus .android and .ios in module projects.
  • Generated files: ios/Flutter/Generated.xcconfig, flutter_export_environment.sh, Flutter.podspec and .flutter-plugins-dependencies.
  • It leaves ios/Pods, Podfile.lock, android/.gradle, pubspec.lock, the shared pub cache and Xcode's DerivedData alone.

flutter clean works on the project in the current folder. It removes:

cd my_app
flutter clean
flutter pub get
flutter run

# also run xcodebuild clean on the iOS and macOS workspaces (slow)
flutter clean --include-xcode-workspace

# Windows: stop Gradle daemons that lock files in build/
flutter clean --stop-gradle

How to clear, repair or prune the pub cache

  • Mac and Linux: ~/.pub-cache. Windows: %LOCALAPPDATA%\Pub\Cache. If the PUB_CACHE environment variable is set, the cache is there instead.
  • dart pub cache clean (or flutter pub cache clean) deletes everything in the cache after asking you to confirm. Add --force or -f to skip the question. Then run flutter pub get in each project.
  • Cleaning also removes packages you installed with dart pub global activate, such as FVM if you installed it that way. Activate them again afterwards.
  • dart pub cache repair downloads cached packages again when files are broken. In recent Dart versions it only repairs the current project's packages; add --all for the whole cache.
  • dart pub cache gc, new in Dart 3.11 (Flutter 3.41 and later), removes only the packages none of your current projects use. --dry-run lists them first.
  • Before Dart 2.8, Windows kept the cache in %APPDATA%\Pub\Cache. Dart 3 no longer reads that folder, so a leftover copy there can be deleted.
dart pub cache gc --dry-run   # what pruning would remove
dart pub cache gc
dart pub cache repair
dart pub cache clean --force

# or delete the folder yourself
rm -rf ~/.pub-cache
Remove-Item -Recurse -Force "$env:LOCALAPPDATA\Pub\Cache"   # Windows PowerShell

Reset the Flutter SDK's own cache (bin/cache)

Inside the Flutter SDK folder, bin/cache holds the Dart SDK, the compiled flutter tool and the engine files for each platform. Flutter's own note in that folder says the tools sometimes delete files there themselves. Deleting the whole folder is safe: the next flutter command downloads the Dart SDK, rebuilds the tool and fetches the engine files again, which needs an internet connection and takes a few minutes. Do it when flutter commands fail with snapshot or artifact errors after an interrupted upgrade, and not while a flutter command is running.

flutter doctor -v prints the SDK path in its Flutter section. flutter precache downloads artifacts ahead of time, and --force downloads them again even if they look current. With FVM, every version in ~/fvm/versions has its own bin/cache; fvm list shows which versions nothing uses, and fvm remove deletes one.

flutter doctor -v                  # shows: Flutter version ... at /path/to/flutter
rm -rf ~/develop/flutter/bin/cache  # use your path
flutter --version                  # downloads it again
flutter precache --force --ios      # or --android, --web, --macos

The iOS and Android caches flutter clean leaves

  • CocoaPods: in ios, delete Pods and run pod install. Keep Podfile.lock unless you want newer pod versions. pod cache clean --all empties CocoaPods' shared download cache.
  • Xcode: DerivedData lives in ~/Library/Developer/Xcode/DerivedData. Quit Xcode before deleting it; the guide to freeing up Xcode disk space covers it.
  • Gradle: android/.gradle in the project and ~/.gradle/caches in your home folder are Gradle's, not Flutter's. The guide to clearing the Gradle cache covers both.
  • IDE caches: in Android Studio, File > Invalidate Caches. In VS Code, run Dart: Restart Analysis Server from the command palette.
cd ios
rm -rf Pods
pod install
cd ..

Clean every Flutter project at once

Flutter has no command for this, but find can run flutter clean in every folder with a pubspec.yaml. List them first. Skipping hidden folders keeps it out of .dart_tool, ios/.symlinks and .fvm, which hold copies of other packages. Run it from the folder that holds your projects.

cd ~/projects
# the projects it will clean
find . -name pubspec.yaml -not -path '*/.*' -not -path '*/build/*' -not -path '*/node_modules/*'

# how much build/ and .dart_tool take now
find . -type d \( -name build -o -name .dart_tool \) -prune -exec du -sh {} + | sort -h

# clean them all
find . -name pubspec.yaml -not -path '*/.*' -not -path '*/build/*' -not -path '*/node_modules/*' -execdir flutter clean \;

# Windows PowerShell
cd $HOME\projects
Get-ChildItem -Recurse -File -Filter pubspec.yaml -ErrorAction SilentlyContinue |
  Where-Object { $_.FullName -notmatch '\\\.|\\build\\|\\node_modules\\' } |
  ForEach-Object { Push-Location $_.DirectoryName; flutter clean; Pop-Location }

Clearing old projects with Stackyard

Stackyard is a free, open-source app for Windows and Mac. It scans your project folders and clears build folders, node_modules and Pods in projects you haven't touched in months in one go, and they come back on the next build. It only removes rebuildable folders such as build, .dart_tool and Pods, shows each one before anything happens, and moves them to the Trash or Recycle Bin. It never edits your code. Its Flutter page also lists each installed Flutter version, FVM's included, with the projects that use it, so you can remove the ones nothing needs. For the pub cache and the SDK's bin/cache, use the commands above.

Questions

Does flutter clean clear the pub cache?

No. It only deletes the project's build/, .dart_tool/ and generated files. The shared pub cache stays until you run dart pub cache clean or delete ~/.pub-cache.

Is it safe to delete the .pub-cache folder?

Yes. Packages download again on the next flutter pub get, which needs a network connection. Packages installed with dart pub global activate are removed too, so activate them again.

How do I clear the Flutter cache and rebuild?

Run flutter clean, then flutter pub get, then flutter run or flutter build. On iOS, if pods are stale, also delete ios/Pods and run pod install.

What does flutter pub cache clean --force do?

The same as dart pub cache clean, without asking you to confirm first. It empties the whole pub cache for every project on the machine.

Does flutter clean delete the Pods folder?

No. It deletes Flutter's generated iOS files but leaves ios/Pods and Podfile.lock. Delete Pods yourself and run pod install if CocoaPods is the problem.