source_gen
provides utilities for automated source code generation for Dart:
- A framework for writing Builders that consume and produce Dart code.
- A convention for human and tool generated Dart code to coexist with clean separation, and for multiple code generators to integrate in the same project.
Its main purpose is to expose a developer-friendly API on top of lower-level
packages like the analyzer or build. You don't have to use
source_gen
in order to generate source code; we also expose a set of library
APIs that might be useful in your generators.
Add a dependency on source_gen
in your pubspec.
dependencies:
source_gen:
If you're only using source_gen
in your own project to generate code and you
won't publish your Generator for others to use, it can be a dev_dependency
:
dev_dependencies:
source_gen:
Once you have source_gen
setup, you should reference the examples below.