build method
Generates the outputs for a given BuildStep
.
Implementation
@override
Future<void> build(BuildStep buildStep) async {
final resolver = buildStep.resolver;
if (!await resolver.isLibrary(buildStep.inputId)) return;
final lib = LibraryReader(await buildStep.inputLibrary);
final annotation = TypeChecker.fromRuntime(DataRepository);
final members = [
for (final member in lib.annotatedWith(annotation)) member,
];
if (members.isNotEmpty) {
await buildStep.writeAsString(
buildStep.inputId.changeExtension('.flutter_data.info'),
members.map((member) {
return [
member.element.name!,
member.annotation.read('internalType').isNull
? DataHelpers.internalTypeFor(member.element.name!)
: member.annotation.read('internalType').stringValue,
member.element.location!.components.first,
member.annotation.read('remote').boolValue,
].join('#');
}).join(';'));
}
}