getAnnotationsFromField method

Future<List<Annotation>> getAnnotationsFromField(
  1. Type type1,
  2. String propertyName
)

Implementation

Future<List<Annotation>> getAnnotationsFromField(
  Type type1,
  String propertyName,
) async {
  var type = reflectClass(type1);
  FieldDeclaration? field = await _getField(type, propertyName);
  while (field == null) {
    type = type.superclass!;
    if (type.reflectedType == Object) {
      break;
    }
    field = await _getField(type, propertyName);
  }

  if (field == null) {
    return [];
  }

  return field.metadata;
}