@pavelgj This is what I was trying to achieve. Generate a line:
new import_2.Key(import_0.ClassOne): (f) => new import_0.ClassOne(f(import_0.Log, [])),

To get that I need this part "import_2" which is defined as
import "package:di/di.dart" as import_2;

typesToImport are a map which contains following structure
K: /Users/markovuksanovic/devel/di.dart/lib/key.dart:Key
V: package:di/di.dart

I was wondering what is the best way to get import_xxx.Key(...) part. Key.toString is overridden already so I'm not sure how to get this "Key" in string. This is obviously wrong.

As for deferred loading, I believe when I run generator_test.dart then di.dart is not imported for some reason. That way I won't be able to get Key. Should I somehow import di.dart. Assuming yes, which is the best way to do that?