Get a better understanding of your Flutter Riverpod dependency graph with the riverpod_graph markup generator
Pictures make it easier to understand how an application is wired together. This is especially true if your application is reactive with different modules listening for changes and making data changes. Riverpod has a graph generator that can show you how its providers are wired together.
Opt 1: Use a checked-out copy of the Riverpod GitHub repo
I generated the following diagram for the example todos application using these riverpod_graph commands. They assume that I have the Riverpod git repository checked out and that I am in a terminal sitting in the root of the repository. The riverpod_graph command accepts the analysis target root as a parameter. I explicitly specified the lib directory here to make sure we didn't pick up any dependencies on utilities or tests.
This approach makes sense if you think you want to work on the riverpod_graph project or that you always want the latest from git and don't want to remember to activate later versions.
mermaid.js format
d2 format
Opt 2: Activating a copy in the Dart global cache
dart pub global activate -sgit https://github.com/rrousselGit/riverpod.git --git-path packages/riverpod_graph
cd to the directory that contains the project that you wish to analyze
dart pub global run riverpod_graph . > graph.md
Deactivating riverpod_graph from your global cache
dart pub global deactivate riverpod_graph
Comments
Post a Comment