SharedPartBuilder class

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.


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.
buildExtensions Map<String, List<String>>
Mapping from input file extension to output file extensions.
formatOutput String Function(String)
Function that determines how the generated code is formatted.
hashCode int
The hash code for this object.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited


build(BuildStep buildStep) Future<void>
Generates the outputs for a given BuildStep.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
toString() String
A string representation of this object.


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