getAnnotation function

ConstantReader? getAnnotation(
  1. Element element,
  2. Type type
)

Implementation

ConstantReader? getAnnotation(Element element, Type type) {
  final annotations = element.metadata.annotations;

  for (var annot in annotations) {
    var annotation = ConstantReader(annot.computeConstantValue());
    if (annotation.instanceOf(typeChecker(type))) {
      return annotation;
    }
  }
  return null;
}