getAsDateTime method

DateTime getAsDateTime(
  1. K key, [
  2. DateTime? orElse

Retrieves the element of key of type Map from Map.

If it is an int type, convert it to a DateTime type with DateTime.fromMillisecondsSinceEpoch.

If there is no element of key in Map or the type does not match int or DateTime, orElse is returned.





DateTime getAsDateTime(K key, [DateTime? orElse]) {
  if (!containsKey(key)) {
    return orElse ??;
  if (this[key] is int?) {
    final millisecondsSinceEpoch = this[key] as int?;
    if (millisecondsSinceEpoch == null) {
      return orElse ??;
    return DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch);
  } else if (this[key] is DateTime?) {
    return (this[key] as DateTime?) ?? orElse ??;
  } else {
    return orElse ??;