SharedPartBuilder class Null safety

A Builder which generates content intended for part of files.

Generated files will be prefixed with a partId to ensure multiple SharedPartBuilders can produce non conflicting part of files. When the source_gen|combining_builder is applied to the primary input these snippets will be concatenated into the final .g.dart output.

This builder can be used when multiple generators may need to output to the same part file but PartBuilder can't be used because the generators are not all defined in the same location. As a convention most codegen which generates code should use this approach to get content into a .g.dart file instead of having individual outputs for each building package.

Available Extensions


SharedPartBuilder(List<Generator> generators, String partId, {String formatOutput(String code)?, List<String> additionalOutputExtensions = const [], bool allowSyntaxErrors = false})
Wrap generators as a Builder that generates part of files. [...]


allowSyntaxErrors bool
Whether to allow syntax errors in input libraries.
final, inherited
buildExtensions Map<String, List<String>>
Mapping from input file extension to output file extensions. [...]
final, inherited
formatOutput String Function(String)
Function that determines how the generated code is formatted.
final, inherited
hashCode int
The hash code for this object. [...]
read-only, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited


build(BuildStep buildStep) Future
Generates the outputs for a given BuildStep.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed. [...]
toString() String
A string representation of this object. [...]


operator ==(Object other) bool
The equality operator. [...]