r/FlutterDev • u/LegitimateItem6658 • Oct 17 '26
Dart Your Flutter codebase is probably carrying 20–30% dead weight — and flutter analyze won't tell you. Here is why every team needs detect_unused_code (v3.2.0)
Every Growing Flutter Codebase Eventually Faces the Same Hidden Problem
You run flutter analyze in your CI/CD. It passes with 0 warnings. Everyone thinks the codebase is in pristine health.
In reality, technical debt has been piling up silently:
- 📦 Forgotten Widgets & Screens: Refactored pages leave behind abandoned dialogs, buttons, and views that nothing calls anymore.
- 🖼️ Bloated App Bundles: Old promo banners, unused 3.0x raster images, and unused SVG icons inflating your APK / IPA size by tens of megabytes.
- 👻 Ghost Dependencies: Packages declared in
pubspec.yamlthat are no longer imported anywhere, slowing down build times andpub geton CI. - 🧟 Dead Logic: Thousands of lines of commented-out code and abandoned TODOs confusing new engineers during onboarding.
🤔 Why doesn't standard dart analyze catch this?
Because Dart treats every public class as a potential export. The compiler intentionally refuses to warn you if a public Widget, Bloc, or Service has 0 references, assuming it "might be needed later".
🚀 The Solution: detect_unused_code (v3.2.0)
We built this tool to turn code audits and refactoring from an anxious, manual chore into a safe, 10-second automated process.
💡 Why Engineering Teams & Companies Use It:
- 📉 Drastically Reduce App Size: Immediately locate and purge megabytes of abandoned images, fonts, and heavy dependencies before publishing to Google Play / App Store.
- ⚡ Faster CI/CD & Build Times: Clean up unreferenced packages and thousands of lines of dead AST syntax that the compiler compiles for nothing.
- 🛡️ 100% Defensive Safety (Zero Fear of Breaking Production):
- Automatic Snapshots: Saves an isolated backup before modifying anything.
- Instant Undo (
[U]or--undo): Revert any cleanup in 1 second. - Automated Compiler Health Check: Runs analysis after cleanup to ensure 0 compiler errors. If anything looks off, it prompts for an auto-rollback.
- Smart Framework Guards: Safely protects
@injectable,@singleton,@riverpod, and generated files (.g.dart,.freezed.dart).
- 🪶 Zero External Runtime Dependencies: Lightweight, runs natively on any Dart SDK from
2.17.0to3.x/4.x. - 🚦 CI/CD Gatekeeper: Add
detect_unused --markdownto GitHub Actions to prevent dead code and unused assets from ever getting merged intomain.
🖥️ The New Interactive Terminal Dashboard:
With v3.2.0, you don't even need to memorize command-line flags. Just run:
&
View all comments
Show parent comment
1
u/LegitimateItem6658 Oct 17 '26
I will try to fix it soon 🙏🏻, and I'm sorry again 🙏🏻