modelToViewValue method

  1. @override
String? modelToViewValue(
  1. DateTime? modelValue
)

Returns the value that must be supplied to the UI widget.

Converts value from control data type to UI data type.

Implementation

@override
String? modelToViewValue(DateTime? modelValue) {
  final dobAge = accessor.modelToViewValue(modelValue);

  if (dobAge == null || (dobAge.years == 0 && (dobAge.months == 0))) {
    existingYear = '';
    existingDays = '';
    return null;
  }

  existingYear = dobAge.years.toString();
  existingDays = dobAge.days.toString();
  int months = dobAge.months;
  return months.toString();
}