flutter clean: how to clear Flutter cache on Mac

The flutter clean command clears the build cache of a Flutter project: it deletes the project’s build and .dart_tool folders. Your code and settings stay. Packages downloaded for all projects live elsewhere, in the pub cache, and the Android and iOS parts of a Flutter app add caches of their own.

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned
  1. Open MacWashing and choose System Junk in the sidebar.
  2. Click Start Scan.
  3. Look through what it found and click Clean. Anything debatable stays unchecked.

Free trial · macOS 14 or later

What flutter clean deletes

This command deletes the build and .dart_tool folders of the project, with everything Flutter compiled there. Your code, pubspec.yaml, assets and the android and ios folders stay. Run it in the project folder:

flutter clean

The next run or build compiles the app from scratch, so it takes noticeably longer. Use it when a build shows old code or fails for no clear reason, or to free the space of a project you don’t work on.

Clean old Flutter projects

A build folder of a Flutter app built for Android and iOS can take hundreds of megabytes, and every project keeps its own. The command works on one project at a time, so run it in each project you’re not working on now. Nothing is lost: the folders come back with the next build.

How to clear Flutter cache: the pub cache

Packages from pub.dev are downloaded once for all projects and kept in the pub cache, ~/.pub-cache. This command deletes the whole pub cache:

dart pub cache clean

If it asks for confirmation, type y and press Return. Projects stay, but before the next build run this in each one, and it downloads its packages again:

flutter pub get

Tools installed globally with pub live in the same folder, so they may need activating again.

When packages seem damaged rather than too big, repair the cache instead. This reinstalls every package in it:

dart pub cache repair

Caches of the Android and iOS parts

With MacWashing, it’s one click

MacWashing, System Junk: Xcode junk, user caches, installers and logs found, 22.83 GB ready to be cleaned

MacWashing doesn’t clean the build folders of Flutter projects: that is what flutter clean is for. System Junk shows Dart’s pub cache and the Gradle cache under App Caches, unchecked, so you decide, and clears the caches of your other apps and tools.

Free trial · macOS 14 or later

Questions and answers

Will MacWashing delete my own files when it cleans?

No. It removes only what it can match to a known app or a known kind of junk, in places apps leave files; macOS and Apple’s files are never touched. Anything debatable is marked and stays unchecked until you decide.

What about apps that are open?

If an open app holds files being cleaned, MacWashing waits for it to quit or quits it at your request, and opens it again afterwards.

Is it free?

Yes, within the free trial: System Junk and the Uninstaller free up to 25 GB in total, with no account or card needed.

Is it safe to run flutter clean?

Yes. It deletes only what Flutter builds itself, in build and .dart_tool. The next build makes them again.

Does flutter clean clear the pub cache?

No. The pub cache in ~/.pub-cache is shared by all projects and stays. To clear it, run: dart pub cache clean

Why is the first build after flutter clean so slow?

Flutter compiles everything again, and the Android and iOS parts are rebuilt with Gradle and Xcode. Later builds reuse what this one made and are faster.