schultek / super_annotations

Write your code generation functions naturally alongside your normal code. Define and use custom annotations in the same file or project.
https://pub.dev/packages/super_annotations
MIT License
39 stars 5 forks source link

How can we generate import in g.dart file #1

Closed bluegearapps closed 2 years ago

bluegearapps commented 2 years ago

Thank you for the great plugin! How can we create import for .g.dart file? i have a bunch of similar imports need to be added to each .g.dart file. Thank you!

schultek commented 2 years ago

You can add import directives to your output like this:

@override
void apply(Class target, LibraryBuilder output) {
  output.directives.add(Directive.import('package:my_package/my_file.dart'));
}