renderSerialization<T extends Object?> method
The serialization of this field in a form of String.
Implementation
String renderSerialization<T extends Object?>(
final ClassModel model,
final FieldModel field,
) {
final String converter = renderConverter(model, field);
switch (field.type) {
case FieldType.$object:
case FieldType.$enum:
case FieldType.$boolean:
case FieldType.$integer:
case FieldType.$float:
case FieldType.$string:
case FieldType.$datetime:
case FieldType.$timedelta:
return converter.isEmpty
? field.name
: '$converter.toJson(${field.name})';
case FieldType.$$object:
case FieldType.$$enum:
case FieldType.$$boolean:
case FieldType.$$integer:
case FieldType.$$float:
case FieldType.$$string:
case FieldType.$$datetime:
case FieldType.$$timedelta:
final String q = field.nullable ? '?' : '';
return converter.isEmpty
? '${field.name}$q.toList(growable: false)'
: '$converter.toJson(${field.name})$q.toList(growable: false)';
}
}