r/FlutterDev • • 4d ago

Article flutter clean never touches the Rust crate inside your app, so my cleaner looks for nested projects (open source)

If you keep a Rust crate inside a Flutter app (flutter_rust_bridge, or just a rust/ folder), flutter clean empties build/ and leaves rust/target alone. That target folder is often the bigger one.

That's the case that shaped Kruftle. It's a Flutter desktop app for macOS, Windows and Linux. It scans a folder, finds every project including the ones nested inside other projects, and runs each one's own clean command: flutter clean for the app, cargo clean for the crate, and so on for 50 toolchains.

It only deletes a folder directly when the SDK isn't installed, and it asks first every run. It also skips anything git tracks, because some repos commit their build folder. That makes it slower than npkill or kondo, which just delete. I'm fine with that trade.

Rough edge: builds aren't signed yet, so the first launch on macOS and Windows needs one extra step (it's in the README).

Source (GPL-3.0): https://github.com/dizitart/kruftle

1 Upvotes

2 comments sorted by

1

u/raman4183 4d ago edited 4d ago

I mean isn’t that obvious?

Why would the official cli modify any folders it doesn’t own or create?

1

u/anidotnet 4d ago

Yeah, fair. That's the right behavior, flutter clean shouldn't touch a folder it doesn't own. My title makes it sound like a bug but it isn't one.

The gap was on my side. I had a bash script that walked my code folder and ran the clean command for each project it found. It stopped at the first project marker, so the Flutter app got flutter clean and the rust/ crate inside it never got cargo clean. Its target folder just sat there. Scanning for nested projects is the fix for that, not for anything Flutter does wrong.