Search code examples
dartfluttermetaprogrammingcode-generationdart-pub

How to write a builder for flutter like json_serializable


I want do some code gen work with flutter.

I found flutter packages pub run build_runner build can do code gen work.

But in the document: https://pub.dartlang.org/packages/build_runner say: "build_runner can only run Builders that are published with a build.yaml file."

I want to known how to make a custom builder or anything else to gen dart code like json_serializable.

Thank you very much!


Solution

  • Why not just look at the source for that package? https://github.com/dart-lang/json_serializable