getAsDateTime method
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.
int型の場合はDateTime.fromMillisecondsSinceEpochでDateTime型に変換します。
Implementation
DateTime getAsDateTime(K key, [DateTime? orElse]) {
if (!containsKey(key)) {
return orElse ?? DateTime.now();
}
if (this[key] is int?) {
final millisecondsSinceEpoch = this[key] as int?;
if (millisecondsSinceEpoch == null) {
return orElse ?? DateTime.now();
}
return DateTime.fromMillisecondsSinceEpoch(millisecondsSinceEpoch);
} else if (this[key] is DateTime?) {
return (this[key] as DateTime?) ?? orElse ?? DateTime.now();
} else {
return orElse ?? DateTime.now();
}
}