firstAnnotationOf method

ElementAnnotation? firstAnnotationOf(
  1. Element element
)

Examines the annotations on element related to this type checker. Examines the annotations on element related to this type checker.

Returns the first annotation on element that is assignable to this type.

Implementation

/// {@macro annotation_check}
///
/// Returns the first annotation on [element] that is assignable to this type.
ElementAnnotation? firstAnnotationOf(Element element) {
  if (element.metadata.isEmpty) {
    return null;
  }
  final Iterable<ElementAnnotation> results = annotationsOf(element);
  return results.isEmpty ? null : results.first;
}