getOrSetDefault<V> method

V? getOrSetDefault<V>(
  1. String key,
  2. V? defaultValue
)

Gets key value. If absent sets the key value to defaultValue and returns it.

Note, this State should be already loaded isLoaded.

Implementation

V? getOrSetDefault<V>(String key, V? defaultValue) {
  if (!_properties.containsKey(key)) {
    _properties[key] = defaultValue;
    _notifyChange(StateOperation.set, key, defaultValue);
    return defaultValue;
  } else {
    return _properties[key] as V?;
  }
}