toDateTime static method

DateTime? toDateTime({
  1. required String date,
  2. required String inputFormat,
})

Implementation

static DateTime? toDateTime({
  required String date,
  required String inputFormat,
}) {
  DateTime? dateTime;
  try {
    dateTime = DateFormat(inputFormat).parse(date);
  } catch (e) {
    dateTime = null;
  }
  return dateTime;
}