dependency_lens_core
Core dependency graph scanner and cycle detector for Dart and Flutter modular workspaces.
This package powers dependency_lens, a DevTools extension and CLI that visualizes
local package dependencies, reports cyclic dependencies, and identifies unused
local path dependencies.
What it scans
dependency_lens_core analyzes local packages in a workspace. By default it
discovers the root package plus packages under:
modules/*plugins/*packages/*
The scanner combines two sources of truth:
- declared local
pathdependencies frompubspec.yaml - actual
package:imports and exports from configured source roots
Cycles are reported with deterministic dependency paths. Declared local dependencies that are not imported or exported are reported as unused dependencies.
Usage
import 'package:dependency_lens_core/dependency_lens_core_io.dart';
Future<void> main() async {
final report = await DependencyLensScanner.io(rootPath: '.').scan();
for (final cycle in report.cycles) {
print(cycle.packageNames.join(' -> '));
}
}
Configuration
Use DependencyLensConfig to customize package roots, scanned source roots,
dependency sections, excluded packages, ignored directories, and ignored
generated file suffixes.
const config = DependencyLensConfig(
localPackageRoots: <String>['modules', 'packages'],
sourceRoots: <String>['lib', 'test'],
dependencySections: <String>['dependencies'],
excludedPackagePaths: <String>{'plugins/example_plugin/example'},
);
The same configuration can be loaded from or serialized to the
dependency_lens.yaml format used by the CLI and DevTools extension.
Libraries
- dependency_lens_core
- Scans Dart and Flutter workspaces for local package dependency edges, dependency cycles, missing direct declarations, and unused declarations.
- dependency_lens_core_io
- IO-backed entrypoint for scanning a local Dart or Flutter workspace.