maybeWhen<_T> method
_T
maybeWhen<_T>({})
Implementation
_T maybeWhen<_T>({
required _T Function() orElse,
_T Function(String ref)? ref,
_T Function(T value)? single,
_T Function(List<CompVal<T>> values)? list,
}) {
final v = this;
if (v is CompValueRef<T>) {
return ref != null ? ref(v.ref) : orElse.call();
} else if (v is CompValueSingle<T>) {
return single != null ? single(v.value) : orElse.call();
} else if (v is CompValueList<T>) {
return list != null ? list(v.values) : orElse.call();
}
throw Exception();
}