SharedPartBuilder constructor
SharedPartBuilder(})
Wrap generators
as a Builder
that generates part of
files.
partId
indicates what files will be created for each .dart
input. This extension should be unique as to not conflict with other
SharedPartBuilders. The resulting file will be of the form
<generatedExtension>.g.part
. If any generator in generators
will
create additional outputs through the BuildStep
they should be indicated
in additionalOutputExtensions
.
formatOutput
is called to format the generated code. Defaults to
DartFormatter.format
.
allowSyntaxErrors
indicates whether to allow syntax errors in input
libraries.
Implementation
SharedPartBuilder(
List<Generator> generators,
String partId, {
String Function(String code)? formatOutput,
List<String> additionalOutputExtensions = const [],
bool allowSyntaxErrors = false,
}) : super(
generators,
formatOutput: formatOutput,
generatedExtension: '.$partId.g.part',
additionalOutputExtensions: additionalOutputExtensions,
header: '',
allowSyntaxErrors: allowSyntaxErrors,
) {
if (!_partIdRegExp.hasMatch(partId)) {
throw ArgumentError.value(
partId,
'partId',
'`partId` can only contain letters, numbers, `_` and `.`. '
'It cannot start or end with `.`.',
);
}
}