getFromMap method
Implementation
String getFromMap({
required String columnName,
required String type,
required bool isRequired,
}) {
String value =
"map['${columnName.snakeCase}']${isRequired ? ' ?? ${getDefaultType(type)}' : ''}";
if (type == 'int') {
value =
"int.tryParse(map['${columnName.snakeCase}']?.toString() ?? '') ${isRequired ? ' ?? ${getDefaultType(type)}' : ''}";
} else if (type == 'double') {
value =
"double.tryParse(map['${columnName.snakeCase}']?.toString() ?? '') ${isRequired ? ' ?? ${getDefaultType(type)}' : ''}";
} else if (type == 'bool') {
value = "map['${columnName.snakeCase}'] == 1";
}
return "${columnName.camelCase}: $value,";
}