Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How run flutter 'packages pub run build_runner build' with debug mode in intellij idea?

I want to put break point on my generator code, but I don't know how to run the command on the debug mode.

I wrote generator using source_gen and build_runner

class MyGenerator extends GeneratorForAnnotation<Todo> {
  @override
  FutureOr<String> generateForAnnotatedElement(
      Element element, ConstantReader annotation, BuildStep buildStep) {
    return "// Hey! Annotation found!";
  }
}
like image 402
Ivan Avatar asked Oct 30 '19 15:10

Ivan


1 Answers

  1. run commad flutter packages pub run build_runner build*

  2. copy build.dart to root folder of project

enter image description here

  1. add new run configuration enter image description here
  2. run debug, now you can debug your code generator!

* the packages is optional, you can just run flutter pub run build_runner build

like image 64
Ivan Avatar answered Oct 14 '22 07:10

Ivan