build method
Generates the outputs for a given BuildStep
.
Implementation
@override
Future<void> build(BuildStep buildStep) async {
final inputId = buildStep.inputId;
final withoutExtension = inputId.path.substring(0, inputId.path.length - '.abi.json'.length);
final source = json.decode(await buildStep.readAsString(inputId));
Documentation? documentation;
String abiCode;
if (source is Map) {
abiCode = json.encode(source['abi']);
} else {
// Remove unnecessary whitespace
abiCode = json.encode(source);
}
final abi = ContractAbi.fromJson(abiCode, _suggestName(withoutExtension));
if (source is Map) {
final doc = source['devdoc'];
if (doc is Map) documentation = Documentation.fromJson(doc.cast(), abi);
}
final outputId = AssetId(inputId.package, '$withoutExtension.g.dart');
await buildStep.writeAsString(outputId, _generateForAbi(abi, abiCode, documentation));
}