convert the input to a date, or null if the input is not a date
DateTime? toDate(String str) { try { return DateTime.parse(str); } on FormatException { return null; } }