build method

  1. @override
Future build(
  1. BuildStep buildStep
)

Generates the outputs for a given BuildStep.

Implementation

@override
Future build(BuildStep buildStep) async {
  // Each [buildStep] has a single input.
  var inputId = buildStep.inputId;

  // Create a new target [AssetId] based on the old one.
  var contents = await buildStep.readAsString(inputId);

  var objectName = generateMessageObjectName(inputId.pathSegments.last);
  var dartContent = generateDartContentFromYaml(objectName, contents);

  var copy = inputId.changeExtension('.dart');

  // Write out the new asset.
  await buildStep.writeAsString(copy, dartContent);
}