setValueVariableMapper method

String setValueVariableMapper(
  1. String key,
  2. dynamic value,
  3. TypeMapper typeMapper
)

Implementation

String setValueVariableMapper(
    String key, dynamic value, TypeMapper typeMapper) {
  if (value is List && value.firstOrNull is Map) {
    return '${key.camelCase}?.map((e) => e.${typeMapper == TypeMapper.toEntity ? 'toEntity' : 'toResponse'}()).toList()';
  } else if (value is Map) {
    return '${key.camelCase}?.${typeMapper == TypeMapper.toEntity ? 'toEntity' : 'toResponse'}()';
  } else {
    return key.camelCase;
  }
}