Skip to main content

flutter_trim 1.2.0 copy "flutter_trim: ^1.2.0" to clipboard
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:line text 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|none option.

🧮 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, abstract and external fields, 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-]variables flag and scan.variables config 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 --restore brings 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-backup turns 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.dart for gateWayController.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 #

  • --json prints a machine-readable report.
  • --fail-on-findings exits with code 1 when anything unused is found.

Renamed #

  • Executables ftrim / flutter_trim (were fsweep / flutter_sweeper).
  • Config file flutter_trim.yaml; markers // flutter_trim:keep and // flutter_trim:ignore_file.
  • Library package:flutter_trim/flutter_trim.dart; SweepItem is now TrimItem, SweeperConfig is TrimConfig, SweeperCommandRunner is TrimCommandRunner, SweeperException is TrimException, SweepReporter / SweepStats are TrimReporter / 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:analyzer 6.x through 14.x (Dart 3.0 to the latest SDK).
1
likes
160
points
165
downloads

Documentation

API reference

Publisher

verified publisherasifzonebd.com

Weekly Downloads

Interactive CLI that finds unused assets, Dart files, classes, methods and variables in Flutter projects. Click to open, delete safely, undo anytime.

Repository (GitHub)
View/report issues
Contributing

Topics

#flutter #cli #cleanup #dead-code #code-quality

License

MIT (license)

Dependencies

analyzer, args, glob, mason_logger, path, yaml

More

Packages that depend on flutter_trim