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.

Constructors

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.

Properties

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

Methods

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

Operators

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