generateSetter function

Method generateSetter (FieldElement field)

Implementation

Method generateSetter(FieldElement field) {
  String code = setterCodeForField(field);

  code += '\n _cache["${field.name}"] = value;';
  return Method((b) => b
    ..name = field.name
    ..body = Code(code)
    ..requiredParameters.add(Parameter((b) => b
      ..name = 'value'
      ..type = refer(field.type.displayName)))
    ..type = MethodType.setter);
}