firstAnnotationOf method
Returns the first constant annotating element assignable to this type.
Otherwise returns null.
Throws on unresolved annotations unless throwOnUnresolved is false.
Implementation
DartObject? firstAnnotationOf(
Element element, {
bool throwOnUnresolved = true,
}) {
if (element.metadata.isEmpty) {
return null;
}
final results =
annotationsOf(element, throwOnUnresolved: throwOnUnresolved);
return results.isEmpty ? null : results.first;
}