build method
Generates the outputs for a given BuildStep
.
Implementation
@override
Future<void> build(BuildStep buildStep) async {
final annotatedElements = await getAnnotatedElements(buildStep);
final contents = await buildStep.readAsString(buildStep.inputId);
final stopwatch = Stopwatch();
stopwatch.start();
final allImports = AggregateBuilder.findAllImports(contents);
final classNamesByFileNames = classFilePathsFromAnnotations(annotatedElements);
final modelDictionaryOutput = modelDictionaryGenerator.generate(classNamesByFileNames);
allImports.removeAll(["import 'dart:convert';", 'import "dart:convert";']);
allImports.removeAll(expectedImportRemovals);
final analyzedImports = allImports
.map((i) => '// ignore: unused_import, unused_shown_name, unnecessary_import\n$i')
.join('\n');
final output = analyzedImports + modelDictionaryOutput;
await manuallyUpsertAppFile('brick.g.dart', output);
await buildStep.writeAsString(buildStep.inputId.changeExtension(outputExtension), output);
logStopwatch('Generated brick.g.dart', stopwatch);
}