Is there a way to see how libraries in my Flutter package depend on each other? Under libraries, I mean internal libraries, dart files under 'lib'. Also, it would be great to check for circular dependencies between the libraries.
Asked
Active
Viewed 1.6k times
3 Answers
117
You can use below command to see your flutter app's dependency graph.
flutter pub deps
The dependency information is printed as a tree, a list, or a compact list.

ibhavikmakwana
- 8,948
- 4
- 20
- 39
-
5It is very interesting to know. However, I am interested to see internal dependencies in my application, not external. I updated my question to make it clear. – polina-c Jul 24 '19 at 17:33
-
4Pass the `--no-dev` option to hide `dev_dependencies`. – Renato Mar 26 '21 at 21:15
-
dude you rock – Mehmet Filiz Sep 02 '23 at 16:45
18
I was also looking for a tool to show internal dependencies but couldn't find one. So I wrote a tool called Lakos to visualize Dart/Flutter library dependencies in Graphviz. Lakos will visualize dependencies inside your project, not external package dependencies. Lakos will also warn about dependency cycles with an exit code.
https://pub.dev/packages/lakos
Example usage:
lakos --metrics . | dot -Tpng -Gdpi=200 -o lakos_example.png
The output will look similar to this:

Oleg Alexander
- 909
- 1
- 7
- 11
-
Beautiful! This worked great for me to understand the screens hierarchy of a new project. – Brandon Mar 30 '22 at 22:00
-
This is really great @Oleg Alexander, exactly what I was looking for! However, the graphs tend to get very hairy for larger projects. Is there a way to produce a graph only at the coarser level of subdirectories (I believe you call them "subgraphs" in lakos)? – user18184 May 14 '22 at 12:34
-
1@user18184 Thanks for the kind words. Unfortunately, there's no way to treat the subdirectories as nodes themselves. But you could try rendering the nodes as points, like this: lakos . | dot -Tpng -Gdpi=200 -Nshape=point -o example.png – Oleg Alexander May 14 '22 at 16:35