findAnnotation function

ElementAnnotation? findAnnotation(
  1. Element element,
  2. Type type
)

Implementation

ElementAnnotation? findAnnotation(Element element, Type type) {
  final typeName = type.toString();
  ElementAnnotation? annotation;
  for (final e in element.metadata) {
    if ((e.element?.displayName == typeName || e.element?.name == typeName)) {
      annotation = e;
      break;
    }
  }
  return annotation;
}