getDateTime static method

DateTime? getDateTime(
  1. String dateStr, {
  2. bool? isUtc,
})

get DateTime By DateStr.

Implementation

static DateTime? getDateTime(String dateStr, {bool? isUtc}) {
  DateTime? dateTime = DateTime.tryParse(dateStr);
  if (isUtc != null) {
    if (isUtc) {
      dateTime = dateTime?.toUtc();
    } else {
      dateTime = dateTime?.toLocal();
    }
  }
  return dateTime;
}