flutter_trim 1.2.0
flutter_trim: ^1.2.0 copied to clipboard
Interactive CLI that finds unused assets, Dart files, classes, methods and variables in Flutter projects. Click to open, delete safely, undo anytime.
Changelog #
1.2.0 — Clickable paths and unused variables #
🔗 Click to open the code #
- Every location in the report tables and on each review card is clickable and opens the file at the reported line.
- VS Code, Cursor and Android Studio / IntelliJ terminals link the
path:linetext themselves; other terminals (iTerm2, WezTerm, kitty, Ghostty, Windows Terminal) get an OSC 8 hyperlink. - Paths are now shown relative to the folder you run ftrim from, so they
stay clickable with
-p ../other_app. - New
--editor auto|vscode|cursor|idea|file|noneoption.
🧮 Unused variables and fields #
- Unused top-level variables/constants and class fields (instance and
static) are reported and can be deleted (or undone) like everything else. - Conservative rules: a field set via
this.x, an initializer list or a named argument counts as used;@override,abstractandexternalfields, and declarations of several variables at once (int a, b;), are never reported. Fields of an unused class go away with the class. - New
--[no-]variablesflag andscan.variablesconfig key (default on).
API #
- New:
DeclarationKind.variable,DeclarationKind.field,Linker,CodeScanner(includeVariables:),TrimConfig.scanVariables,TrimReporter(linker:),InteractivePrompt(linker:).
1.1.1 #
- Documentation: a "What's new" section and a reorganised feature list in the README, a clearer package description. No code changes.
1.1.0 — Undo and restore #
Deleting is no longer final. Every deletion can be brought back.
↺ Undo during the review #
- New Undo last delete choice in the menu. It appears as soon as something was deleted and names the item it will bring back. Choose it again to step further back.
- An undone item counts as kept, and the session summary shows how many were undone.
🛟 Restore later #
ftrim --restorebrings back everything deleted in the most recent session, newest first, so several edits of the same file unwind exactly. Run it again to restore an older session.
💾 Automatic backups #
- Before a file is deleted or a declaration is removed, the original is
copied to
.flutter_trim/backups/<session>/in the project root. If the backup cannot be written, nothing is deleted. - The backup folder is never scanned. Add
.flutter_trim/to.gitignore. --no-backupturns backups off. The "not under git" confirmation is now only shown in that case.
API #
- New:
BackupStore,BackupEntry,backupDirName,FileCleaner(backup:),CleanResult.backupId,PromptDecision.undo,TrimStats.restored/backedUp.
1.0.0 #
First release under the name flutter_trim. It continues
flutter_sweeper 1.0.0, which is
now discontinued.
Accuracy on large projects #
- Import URIs are percent-decoded, so folders with spaces
(
package:app/common%20widget/x.dart) are followed. Previously every file in such a folder was reported as unused. - Imports whose letter case differs from the file on disk
(
gatewayController.dartforgateWayController.dart) are resolved, as they are on macOS and Windows. Previously such files, and everything only they imported, were reported as unused. - Source files with invalid UTF-8 are read leniently instead of being skipped, so their references are never lost. Unreadable files now produce a visible warning.
- Verified on three production apps (400–600 Dart files each): 0 false positives across 134 findings.
New interface #
- Banner, run settings, a summary table and per-category tables that adapt to the terminal width and keep file names visible.
- Each finding is shown as a card with a code preview, a progress bar and running counts.
- Session summary with suggested next steps.
New options #
--jsonprints a machine-readable report.--fail-on-findingsexits with code 1 when anything unused is found.
Renamed #
- Executables
ftrim/flutter_trim(werefsweep/flutter_sweeper). - Config file
flutter_trim.yaml; markers// flutter_trim:keepand// flutter_trim:ignore_file. - Library
package:flutter_trim/flutter_trim.dart;SweepItemis nowTrimItem,SweeperConfigisTrimConfig,SweeperCommandRunnerisTrimCommandRunner,SweeperExceptionisTrimException,SweepReporter/SweepStatsareTrimReporter/TrimStats.
Carried over from flutter_sweeper 1.0.0 #
- Unused asset, unreferenced Dart file and unused declaration detection.
- Safe declaration removal that refuses edits adding syntax errors.
- Works with
package:analyzer6.x through 14.x (Dart 3.0 to the latest SDK).