getAnnotation function

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

Implementation

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

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