getDefaultValue function

String getDefaultValue (FieldElement field, DartObject annotation)

Implementation

String getDefaultValue(FieldElement field, DartObject annotation) {
  var value;
  switch (field.type.displayName) {
    case 'bool':
      value = annotation.getField("value").toBoolValue().toString();
      break;
    case 'int':
      value = annotation.getField("value").toIntValue().toString();
      break;
    case 'String':
      value = "'${annotation.getField("value").toStringValue()}'";
      break;
    case 'List<String>':
      value = annotation
          .getField("value")
          .toListValue()
          ?.map((dob) => "'${dob.toStringValue()}'")
          ?.toList()
          ?.toString();
      if (value == '[]') {
        value = '<String>[]';
      }
      break;
    case 'double':
      value = annotation.getField("value").toDoubleValue().toString();
      break;
  }
  return value;
}