valueToType function

String valueToType(
  1. String? fieldType
)

Implementation

String valueToType(String? fieldType) {
  String response;
  switch (fieldType) {
    case 'int':
      response = 'int.tryParse(value)';
      break;
    case 'double':
      response = 'double.tryParse(value)';
      break;
    case 'bool':
      response = 'value == \'true\'';
      break;
    case 'DateTime':
      response = 'DateTime.tryParse(value)';
      break;
    case null:
    default:
      response = 'value';
  }
  return response + ';';
}