hasAnyAnnotation function

bool hasAnyAnnotation(
  1. AnnotatedNode node,
  2. Iterable<String> annotationNames
)

Checks if an AnnotatedNode has any of the given annotationNames.

Implementation

bool hasAnyAnnotation(AnnotatedNode node, Iterable<String> annotationNames) {
  final nameSet = annotationNames.toSet();
  for (final meta in node.metadata) {
    final rawName = meta.name.name;
    final baseName = rawName.contains('.') ? rawName.split('.').last : rawName;
    if (nameSet.contains(baseName)) {
      return true;
    }
    final constructorName = meta.constructorName?.name;
    if (constructorName != null && nameSet.contains(constructorName)) {
      return true;
    }
  }
  return false;
}