toDateTime static method

DateTime? toDateTime(
  1. String input
)

Converts a string to a DateTime if possible.

Implementation

static DateTime? toDateTime(String input) {
  try {
    return DateTime.parse(input);
  } catch (_) {
    return null;
  }
}