LibraryBuilder constructor

  1. Generator generator, {
  2. String formatOutput(
    1. String code
  3. String generatedExtension = '.g.dart',
  4. List<String> additionalOutputExtensions = const [],
  5. String? header,
  6. bool allowSyntaxErrors = false,
  7. BuilderOptions? options,

Wrap generator as a Builder that generates Dart library files.

generatedExtension indicates what files will be created for each .dart input. Defaults to .g.dart, however this should usually be changed to avoid conflicts with outputs from a SharedPartBuilder. If generator 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.

header is used to specify the content at the top of each generated file. If null, the content of defaultFileHeader is used. If header is an empty String no header is added.

allowSyntaxErrors indicates whether to allow syntax errors in input libraries.


  Generator generator, {
  String Function(String code)? formatOutput,
  String generatedExtension = '.g.dart',
  List<String> additionalOutputExtensions = const [],
  String? header,
  bool allowSyntaxErrors = false,
  BuilderOptions? options,
}) : super(
        formatOutput: formatOutput,
        generatedExtension: generatedExtension,
        additionalOutputExtensions: additionalOutputExtensions,
        header: header,
        allowSyntaxErrors: allowSyntaxErrors,
        options: options,