findTransferIdField function
FieldElement?
findTransferIdField(
- ClassElement element
Implementation
FieldElement? findTransferIdField(ClassElement element) {
final idFields = podoFields(element).map((f) => f.a).where((f) =>
TypeChecker.fromRuntime(TransferId)
.firstAnnotationOfExact(f, throwOnUnresolved: false) !=
null);
if (idFields.length > 1) {
throw Exception('Only 1 TransferId field is allowed on a TransferObject.');
} else if (idFields.isNotEmpty) {
return idFields.single;
} else {
return null;
}
}