dependency_lens
Flutter DevTools extension and CLI for visualizing local module dependencies and detecting cyclic dependencies in Dart and Flutter modular workspaces.
dependency_lens is a DevTools extension package, not a native Android or iOS
Flutter plugin. It scans local Dart and Flutter packages, shows a dependency
matrix and graph, detects dependency cycles, and reports unused declared local
dependencies.
CLI
dart run dependency_lens:dependency_lens scan --root .
Use --format text, --format json, or --format dot. The command exits with
code 1 when dependency cycles are found.
For CI, use the dedicated check command:
dart run dependency_lens:dependency_lens check --root .
It exits with code 0 when no cycles are found and 1 when any cycle is
detected, including multi-package cycles such as a -> b -> c -> a.
Warnings, such as missing direct dependencies, do not fail the check.
To also fail CI for unused local dependencies, pass:
dart run dependency_lens:dependency_lens check --root . --fail-on-unused-dependencies
Configuration
Both the CLI and DevTools UI read dependency_lens.yaml from the workspace root
when it exists. CLI flags override YAML values.
include_root_package: true
local_package_roots:
- modules
- plugins
- packages
source_roots:
- lib
- bin
- test
- tool
dependency_sections:
- dependencies
- dev_dependencies
- dependency_overrides
excluded_package_names: []
excluded_package_paths: []
ignored_directory_names:
- .dart_tool
- .git
- .idea
- .symlinks
- build
- Pods
ignored_file_suffixes:
- .g.dart
- .freezed.dart
- .config.dart
- .module.dart
Both scan and check accept configuration flags backed by DependencyLensConfig:
dart run dependency_lens:dependency_lens scan --root . \
--package-root modules \
--package-root packages \
--source-root lib \
--dependency-section dependencies \
--exclude-package legacy_module \
--exclude-path plugins/example_plugin/example \
--ignore-dir generated \
--ignore-suffix .gen.dart \
--no-root-package
DevTools
Add dependency_lens as a dev_dependency, run flutter pub get, then enable the
extension in Flutter DevTools.
dev_dependencies:
dependency_lens: ^0.1.2
The DevTools UI includes:
- Matrix: package-by-package dependency grid with
D+I,D,I, andUNUSEDcell markers - Graph: interactive dependency graph with direction arrows
- Cycles: exact cycle paths and evidence
- Unused: declared local path dependencies that are not imported or exported
- Settings: editable
dependency_lens.yamlconfiguration
Programmatic usage can pass the same configuration object:
runApp(
const DependencyLensApp(
config: DependencyLensConfig(
localPackageRoots: <String>['modules', 'packages'],
dependencySections: <String>['dependencies'],
excludedPackagePaths: <String>{'plugins/example_plugin/example'},
),
),
);
Libraries
- dependency_lens
- DevTools extension and CLI-facing APIs for Dependency Lens.
- main