Convert string to a DateTime.
string
DateTime? toDate(String string) { try { return DateTime.parse(string); } catch (e) { return null; } }