generate method
Generates Dart code for an input Dart library.
May create additional outputs through the buildStep, but the 'primary'
output is Dart code returned through the Future. If there is nothing to
generate for this library may return null, or a Future that resolves to
null or the empty string.
Implementation
@override
FutureOr<String?> generate(LibraryReader library, BuildStep buildStep) async {
bool debug = options.config.containsKey('debug') ? options.config['debug'] : false;
//parts are not available at build time trough .fragments so we check manually for part declaration:
var fileName = library.element.firstFragment.source.fullName.split('/').last;
var partName = fileName.replaceAll('.dart', '.c.dart');
if (library.element.firstFragment.source.contents.data.contains("\npart '$partName';\n")) {
return await (CompiledOmGenerator(OutputWriter(debug), library, buildStep, DiConfig(), GenerationTimer(), debug)).generate();
}
return null;
}