getAsModelTimestamp method

ModelTimestamp getAsModelTimestamp(
  1. String key, [
  2. DateTime? defaultValue
])

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の要素を取得します。

Mapkeyの要素がない場合や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;
}