getAsModelTimestamp method
Retrieves the element of key
of type ModelTimestamp from Map.
If there is no element of key
in Map or the type does not match ModelTimestamp, ModelTimestamp whose value is defaultValue
is returned.
MapからModelTimestamp型のkey
の要素を取得します。
Mapにkey
の要素がない場合やModelTimestampと型が合わない場合、defaultValue
が値となるModelTimestampが返されます。
Implementation
ModelTimestamp getAsModelTimestamp(String key, [DateTime? defaultValue]) {
if (!containsKey(key) || this[key] is! ModelTimestamp) {
return ModelTimestamp(defaultValue ?? DateTime.now());
}
return this[key] as ModelTimestamp;
}