stringToDateTime static method

DateTime stringToDateTime({
  1. required String date,
  2. String format = Format.fyyyyMMdd,
})

convert date (String to DateTime)

Implementation

static DateTime stringToDateTime(
    {required String date, String format = Format.fyyyyMMdd}) {
  if (_isNullOrEmpty(date)) {
    return DateTime.now();
  } else {
    return DateFormat(format).parse(date);
  }
}