valueEnsureAsSet<T> method

Set<T> valueEnsureAsSet<T>(
  1. K key, {
  2. Set<T> onError(
    1. BuError err
    )?,
  3. Set<T> onMissing()?,
  4. bool normalizeKeyLookup = false,
})

Reads key and casts it to Set<T>.

Implementation

Set<T> valueEnsureAsSet<T>(
  K key, {
  Set<T> Function(BuError err)? onError,
  Set<T> Function()? onMissing,

  /// Only applicable when [K] is `String`.
  bool normalizeKeyLookup = false,
}) {
  try {
    final value = _checkItem<Set>(key, onMissing, normalizeKeyLookup);
    return JsonParser.valueEnsureAsSet<T>(value);
  } on BuError catch (e) {
    if (onError != null) return onError(e);
    throw CoreErrors.jsonErrorWithKey(e, key);
  }
}