build method
Generates the outputs for a given BuildStep
.
Implementation
@override
FutureOr<void> build(BuildStep buildStep) async {
log.info(lightGreen.wrap(
' 🧱 Generating scaffold for ${buildStep.inputId.pathSegments.last}\n'));
final scaffoldId = buildStep.inputId.changeExtension('.scaffold.dart');
final domainSrc = await buildStep.readAsString(buildStep.inputId);
final domainInfo = await _parseDomainInfo(domainSrc);
log.info(lightGreen.wrap(
'🔎 Found Domain Object ${domainInfo.name} with the fields: ${domainInfo.fields.map((e) => e.name)}\n'));
final files = await _generate(buildStep.inputId.package, domainInfo);
log.info(lightGreen.wrap(' 🧱 Generated scaffold files now bundling\n'));
buildStep.writeAsString(
scaffoldId, _bundle(buildStep.inputId.package, files));
log.info(lightGreen.wrap(' ✅ Bundled into $scaffoldId\n'));
}