getOrCompute<T> method

T getOrCompute<T>(
  1. K key,
  2. T computation()
)

Implementation

T getOrCompute<T>(K key, T Function() computation) {
  final thiz = this;
  if (thiz == null) return computation();
  final value = thiz[key];
  return value is T ? value : computation();
}