getApiValue method
dynamic
getApiValue()
Implementation
dynamic getApiValue() {
final String text = controller.text.trim();
switch (type) {
case MahasInputType.text:
return text.isEmpty ? null : text;
case MahasInputType.checkbox:
return (this as MahasCheckboxModel).checked.value;
case MahasInputType.date:
return text.isEmpty
? null
: MahasFormat.getDateFormatApiFromString(text);
case MahasInputType.dateTime:
return text.isEmpty
? null
: MahasFormat.getDateTimeFormatApiFromString(text);
case MahasInputType.currency:
return MahasFormat.getDoubleFromCurrency(text);
case MahasInputType.doubleType:
return double.tryParse(text);
case MahasInputType.intType:
return int.tryParse(text);
default:
return null;
}
}