match<U> method
U
match<U>({
- required U onSuccess(
- T
- required U onError(
- E
Achieves the same thing as a switch expression with pattern matching. You should consider using a switch expression, but sometimes the match function is simpler
Implementation
U match<U>({
required U Function(T) onSuccess,
required U Function(E) onError,
}) =>
switch (this) {
Success(:final value) => onSuccess(value),
Error(error: final e) => onError(e),
};