LayerLens
Generate dependency diagram in every folder of your Dart or Flutter
package as Mermaid flowchart
documents.
NOTE: LayerLens shows inside-package dependencies. For cross-package dependencies use flutter pub deps
.
Configure layerlens
Configure command globally
-
Run
dart pub global activate layerlens
-
Verify you can run
layerlens
. If you getcommand not found
, make sure your path contains pub cache.
Configure command for a package
-
Add
layerlens: <version>
to the sectiondev_dependencies
in the package's pubspec.yaml. -
Run
dart pub get
orflutter pub get
for the package.
Configure IDE
To see the diagrams in your IDE:
-
VSCode: install
Markdown Preview Mermaid Support
extension -
Android Studio: enable the "Mermaid" extension in the Markdown language settings
Generate diagrams
- Run command:
-
With global configuration:
layerlens --path <your package root>
-
With package configuration:
dart run layerlens
in the package root
-
Find the generated file DEPENDENCIES.md in each source folder, where libraries or folders depend on each other.
-
In VSCode, right click DEPENDENCIES.md and select 'Open Preview'
CI: re-generate on every GitHub push
- Add a
dev_dependency
to https://pub.dev/packages/layerlens - Copy the content of run-layerlens.yaml
to
.github/workflows
.
Alert on circular references
You may want to avoid circular references, because without circles:
- Code is easier to maintain
- Chance of memory leaks is smaller
- Treeshaking (i.e. not including non-used code into build) is more efficient
- Incremental build is faster
LayerLens marks inverted dependencies (dependencies that create circles) with '!'.
Also you can add command dart run layerlens --fail-on-cycles
to the repo's pre-submit bots.
Supported languages
While layerlens concepts are language agnostic, for now only dart
is supported.
Please submit an issue, if you want other language to be added.
Contribute to layerlens
See CONTRIBUTING.md
for details.
License
Apache 2.0; see LICENSE
for details.
Disclaimer
This project is not an official Google project. It is not supported by Google and Google specifically disclaims all warranties as to its quality, merchantability, or fitness for a particular purpose.