Skip to main content


Fixes issues produced by dcm analyze, dcm check-unused-code or dcm check-dependencies commands.

To execute the command, run:

$ dcm fix lib # or dcm f lib

Full command description:

-h, --help                                       Print this usage information.

--type=<lints> Type of issues to fix.
[lints (default), unused-code, dependencies]
--apply-to=<{**/*.g.dart}> List of file to apply fixes (all by default).
--dry-run Preview the proposed changes but make no changes.

--include-rules=<rule-id1,rule-id2,...> Include additional lint rules that are not listed in the config.
--exclude-rules=<rule-id1,rule-id2,...> Exclude lint rules from the fixes calculation.
--only-rules=<rule-id1,rule-id2,...> Calculate fixes for only listed rules.

-l, --line-length Wrap lines longer than this.
-i, --indent Add this many spaces of leading indentation.
--[no-]cascading-widget-extensions Format widget extensions in a more readable way.

-c, --print-config Print resolved config.

--root-folder=<./> Root folder.
(defaults to current directory)
--sdk-path=<directory-path> Dart SDK directory path.
If the project has a `.fvm/flutter_sdk` symlink, it will be used if the SDK is not found.
--exclude=<{**/*.g.dart,**/*.freezed.dart}> File paths in Glob syntax to be exclude.
(defaults to "{**/*.g.dart,**/*.freezed.dart}")

--no-congratulate Don't show output even when there are no issues.

--[no-]verbose Show verbose logs.

--ci-key The license key to run on CI server.
--email The email used to purchase the license.

--no-analytics Disable sending anonymous usage statistics.

--[no-]monorepo Treat all exported code as unused by default.

Currently supported rules

Almost all rules that have 🛠 are supported by dcm fix.

Here is the list of the currently not supported rules:

  • avoid-double-slash-imports
  • avoid-top-level-members-in-tests
  • avoid-unsafe-collection-methods
  • correct-game-instantiating
  • match-positional-field-names-on-assignment
  • prefer-correct-future-return-type
  • prefer-correct-stream-return-type
  • prefer-match-file-name
  • prefer-type-over-var
  • tag-name

Overriding rules set

By default the command takes the rules list from the configuration, but you can override this behavior with several CLI options:

  1. --include-rules allows you to add rules that are not listed in your config, but you want to apply their fixes as well
  2. Use --exclude-rules to exclude rules listed in your config from fixes calculation
  3. Use --only-rules to run calculate fixes only for the given list of rules

Dry run

If you want to see the proposed changes without applying them, run the command with the --dry-run option. It will output the code that will be changed marking removed code with the red color and the code that will be added with the green.

Removing unused code

To remove unused code with dcm fix set the --type option to unused-code --type=unused-code. If you have a monorepo, don't forget to pass the --monorepo flag.

Fixing dependency issues

To fix dependency issus with dcm fix set the --type option to dependencies --type=dependencies.