Skip to main content
Teams+

Analyze Structure

Shows how files depend on each other (imports, exports, parts) and how they depend on external packages.

To execute the command, run:

$ dcm analyze-structure lib # or dcm as lib

Full command description:

Usage: dcm analyze-structure [arguments] <directories>
-h, --help Print this usage information.


--show-external-files Show files from directories outside of the analysis root.
--show-external-packages Show imported external packages.
--per-package Summarize to package level.
-m, --modules=</features/[^/]+> Summarize modules to the regexp pattern.
--highlight=</features/[^/]+> Highlight files matching the regexp.


-r, --reporter=<dot> The format of the output of the analysis.
[dot(Pro+) (default)]


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


--root-folder=<./> Root folder.
(defaults to the 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}> Files to exclude (in Glob syntax).
(defaults to "{**/*.g.dart,**/*.freezed.dart}")


--[no-]congratulate Show output even when there are no issues.


--verbose Show verbose logs.


--ci-key The license key to run on CI server. Can be provided via DCM_CI_KEY env variable.
--email The email used to purchase the license. Can be provided via DCM_EMAIL env variable.


--no-analytics Disable sending anonymous usage statistics.

Output Format

The command outputs the structure in GraphViz dot format.

To convert the output to PDF, SVG or PNG, install the graphviz tool on your device.

$ dcm as . | dot -Tpng -Gdpi=200 -o example.png

Alternatively, you can use an online editor.

Notation

Nodes

Graph nodes represent files (or modules) and packages.

Nodes colored with "lightgrey" represent test files.

Nodes colored with "lightsteelblue" represent barrel files.

Nodes colored with "lightcyan" represent generated files.

To highlight specific nodes, pass a regular expression to the --highlight option.

Edges

Edges represent which file (or module) depends on another file (or module) or package.

Unidirectional edges represent regular imports (the arrow points to the importing file).

Dotted edges represent conditional imports / exports.

Grey edges represent re-exports.

Bidirectional edges represent part files relations.

External Imports

By default, local files that are outside of the analysis root are not included into the output.

To show local external files, pass the --show-external-files flag.

To show imported external packages, pass the --show-external-packages flag. Used packages will be separated into 4 categories: Dart, Flutter, Pub and Local.

Grouping

To group files by their containing package, pass the --per-package flag.

To group files by arbitrary folders, pass a regular expression to the --modules option. First folder that matches the regular expression will be converted into a module.

Output Example

Output

With Highlighted Nodes

Highlighted output

Modules Example

Modules output