Skip to main content

Check unused files

Checks unused *.dart files. To execute the command, run

$ dart run dart_code_metrics:metrics check-unused-files lib

# or for a Flutter package
$ flutter pub run dart_code_metrics:metrics check-unused-files lib

Full command description:

Usage: metrics check-unused-files [arguments...] <directories>

-h, --help Print this usage information.


-r, --reporter=<console> The format of the output of the analysis.
[console (default), json]


--root-folder=<./> Root folder.
(defaults to current directory)
--exclude=<{/**.g.dart,/**.template.dart}> File paths in Glob syntax to be exclude.
(defaults to "{/**.g.dart,/**.template.dart}")

Output example

Console

Use --reporter=console to enable this format.

Console

JSON

The reporter prints a single JSON object containing meta information and the unused file paths. Use --reporter=json to enable this format.

The root object fields are

  • formatVersion - an integer representing the format version (will be incremented each time the serialization format changes)
  • timestamp - a creation time of the report in YYYY-MM-DD HH:MM:SS format
  • unusedFiles - an array of unused files
{
"formatVersion": 2,
"timestamp": "2021-04-11 14:44:42",
"unusedFiles": [
{
...
},
{
...
},
{
...
}
]
}

The unusedFiles object fields are

  • path - a relative path of the unused file
{
"path": "lib/src/some/file.dart",
}