build method
Generates the outputs for a given BuildStep
.
Implementation
@override
Future<void> build(BuildStep buildStep) async {
const decoder = JsonDecoder();
final intl = <String, JsonIntlData>{};
print('BUILD');
await for (final file in Glob('${options.source}/*.json').list()) {
log.info('Loading ${file.path}');
final jsonData = await File(file.path).readAsString();
final Map<String, dynamic> json = decoder.convert(jsonData);
final intlData = JsonIntlData();
intlData.append(json);
intl[p.basename(file.path)] = intlData;
}
final gen = Generator(intl: intl, options: options);
final output = gen.createSource();
await buildStep.writeAsString(buildStep.allowedOutputs.first, output);
}