LibraryBuilder constructor

LibraryBuilder(
  1. Generator generator, {
  2. String formatOutput(
    1. String code
    ) = _defaultFormatOutput,
  3. required Set<String> outputExtensions,
  4. bool? writeDescriptions,
  5. String? header,
  6. bool allowSyntaxErrors = false,
  7. BuilderOptions? options,
})

Creates a builder that generates standalone Dart library files.

@param generator The generator to run @param formatOutput Function to format the generated code @param outputExtensions File extensions that this builder will create @param writeDescriptions Whether to include generator descriptions in comments @param header Optional header text for generated files @param allowSyntaxErrors Whether to process files with syntax errors @param options Additional configuration options

Implementation

LibraryBuilder(
  Generator generator, {
  super.formatOutput = _defaultFormatOutput,
  required super.outputExtensions,
  super.writeDescriptions,
  super.header,
  super.allowSyntaxErrors,
  super.options,
}) : super(<Generator>[generator]) {
  for (final String ext in outputExtensions) {
    if (ext == SharedPartBuilder.extension) {
      throw ArgumentError(
        'The LibraryBuilder cannot be used with the shared part extension',
      );
    }
    if (!ext.endsWith('.dart')) {
      throw ArgumentError(
        'LibraryBuilder output extensions must end with .dart',
      );
    }
  }
}