FlutterCleaner is a lightweight, high-performance CLI tool written in Go. It recursively scans your development directories, identifies Flutter projects, and executes flutter clean on them automatically.
🎉 Success Story
The inspiration for this tool came from a real-world need. On its first run, this tool reclaimed 30GB of disk space by removing old build artifacts and cached data from forgotten projects.
Flutter projects generate a significant amount of data in the build/ and .dart_tool/ directories. While necessary for incremental compilation, these folders can grow indefinitely. If you have dozens of projects sitting idle, you are likely wasting gigabytes of storage.
- Automated: No need to manually open terminal windows for every project.
- Fast: Written in Go for speed; ignores hidden folders like
.gitand.ideafor faster traversal. - Safe: Only runs clean commands where a
pubspec.yamlexists.
- Go (Golang) installed on your system.
- Flutter installed and added to your system PATH.
- Clone this repository or download the source code.
- Initialize the module:
go mod init fluttercleaner
- Build the executable:
This will generate a binary file named
go build
fluttercleaner(orfluttercleaner.exeon Windows).
-
Move the
fluttercleanerexecutable to your root projects directory (e.g.,~/ProjectsorD:\Dev). -
Run the tool:
Mac/Linux:
./fluttercleaner
Windows:
fluttercleaner.exe
The tool will print the directories it finds and the status of the clean operation:
Searching for Flutter projects in: /Users/dev/Projects
---------------------------------------------------------
Found project at: /Users/dev/Projects/cool_app
> Running 'flutter clean'... SUCCESS
Found project at: /Users/dev/Projects/old_demo
> Running 'flutter clean'... SUCCESS
---------------------------------------------------------
Done.
The application uses Go's filepath.WalkDir to traverse the file system.
- It looks for any file named
pubspec.yaml. - It verifies the folder is not a hidden directory (starts with
.). - It executes
exec.Command("flutter", "clean")in that directory. - It captures and reports success or failure.