withValueOrDefault<T> method

void withValueOrDefault<T>(
  1. Object? key,
  2. ValueSetter<T> onValue,
  3. T def
)

Implementation

void withValueOrDefault<T>(Object? key, ValueSetter<T> onValue, T def) {
  final thiz = this;
  if (thiz != null && thiz.containsKey(key)) {
    final value = thiz[key];
    if (value is T) {
      onValue(thiz[key] as T);
      return;
    }
  }
  onValue(def);
}