build method

  1. @override
FutureOr<void> build(
  1. BuildStep buildStep
)

Generates the outputs for a given BuildStep.

Implementation

@override
FutureOr<void> build(BuildStep buildStep) async {
  final inputId = buildStep.inputId;
  final outputId = inputId.changeExtension('.idl.dart');
  print('[START]: ${inputId.path} => ${outputId.path}');
  final contents = await buildStep.readAsString(inputId);
  final split = inputId.pathSegments.last.split('.');
  split.removeLast();
  final clazz = split.join('_').pascalCase;
  final code = codegen(clazz, contents);
  await buildStep.writeAsString(outputId, code);
  print('[  END]: ${inputId.path} => ${outputId.path}');
}