5

I have been trying to generate dart diagrams for my code but the below error:

C:\Users\Foldername\AppData\Local\Pub\Cache\bin>dart pub global run dcdg
C:\Users\Foldername\AppData\Local\Pub\Cache\bin\lib

Unhandled exception:

Bad state: Unable to find the context to C:\Users\Foldername\AppData\Local\Pub\Cache\bin\lib\.env.dart
#0      AnalysisContextCollectionImpl.contextFor (package:analyzer/src/dart/analysis/analysis_context_collection.dart:106:5)
#1      findClassElements (package:dcdg/src/find_class_elements.dart:46:39)
#2      main (file:///C:/Users/Foldername/AppData/Local/Pub/Cache/hosted/pub.dartlang.org/dcdg-4.0.1/bin/dcdg.dart:35:25)
#3      _delayEntrypointInvocation.<anonymous closure> (dart:isolate-patch/isolate_patch.dart:295:32)
#4      _RawReceivePortImpl._handleMessage (dart:isolate-patch/isolate_patch.dart:192:12)

1- I have activated the package.

2- I have updated it to the latest.

3- Environment variables are correctly set.

I still don't understand why does it not allow me to create class diagrams for my code. Anyone has any answers?

1 Answers1

0

I think that probably in your project are dependencies that use code-generation (with build_runner) like: freezed, auto_route, localizely or hive. Package dcdg at the moment (ver. 4.1.0) have issues for generating PlantUML file for such projects. If you want to use dcdg you need to refactor your code and remove such dependencies.

Here is github issue related to your case.

Paul Kastel
  • 913
  • 1
  • 13
  • 22