formatDate function

String formatDate(
  1. DateTime? value
)

Formats a DateTime object to a string using the kDateFormat. Returns 'n/a' if the value is null or represents an invalid date.

Implementation

String formatDate(DateTime? value) {
  if (value == null) {
    return 'n/a';
  } else if ((value.compareTo(DateTime.parse('0001-01-01')) == 0) ||
      (value.compareTo(DateTime.parse('1900-01-01')) == 0)) {
    return 'n/a';
  } else {
    return kDateFormat.format(value);
  }
}