Flutter/Dart ~/.pub-cache taking up space: safe to delete?
Where it is
~/.pub-cache/hosted
What it is
Dart's pub tool, which Flutter uses for dependencies, downloads packages from pub.dev into a shared system cache. The hosted folder contains one unpacked directory per package version, and projects reference these directories directly instead of copying them.
Why it gets so big
Every version of every package any project has used stays here, and Flutter plugins often carry native platform code for several platforms. It isn't pruned automatically.
Is it safe to delete?
Yes, with a step afterwards, which is why it's flagged for review. Because projects point straight at these folders, they won't build until you run pub get (or flutter pub get) to download their packages again. Globally activated Dart tools that depend on hosted packages may also need to be reactivated.
Tip
Dart's own pub cache clean command goes further than this cleanup and empties the entire ~/.pub-cache, including git dependencies and global tools.
See how much space it uses
du -sh "$HOME/.pub-cache/hosted" 2>/dev/nullClean it with the tool’s own command
dart pub cache cleanDelete it by hand
Run in Terminal. Deleting cannot be undone, so check the paths first.
rm -rf "$HOME/.pub-cache/hosted"/*