readMapperConfig static method

Map<String, dynamic> readMapperConfig(
  1. ConstantReader annotation,
  2. ClassElement mappingClass
)

Reads the attributes given in the Mapper Annotation, and returns a map, where the key is the attributename, and value the value of the read attribute.

Implementation

static Map<String, dynamic> readMapperConfig(
    ConstantReader annotation, ClassElement mappingClass) {
  var mapper =
      mappingClass.metadata[0].element!.enclosingElement3 as ClassElement;
  final config = <String, dynamic>{};

  for (final field in mapper.fields) {
    final configField = annotation.read(field.name).literalValue;
    config.putIfAbsent(field.name, () => configField);
  }
  return config;
}