resolveOption method

FutureOr<KeyedOption<K, T>?> resolveOption(
  1. K? key
)

Given a key key, this will attempt to resolve it either by: a) loading the value using loadValue b) creating an ad-hoc option

Implementation

FutureOr<KeyedOption<K, T>?> resolveOption(final K? key) {
  if (key == null) return null;
  final loadedValue = this.loadValue(key);
  return key is! String
      ? loadedValue.thenOr(((value) => toOption(value)!))
      : loadedValue.thenOr((lookup) {
          if (lookup != null) return toOption(lookup)!;
          return adhocOptionBuilder?.call(key);
        });
}