when<R> method
R
when<R>({
- required R unauthenticated(),
- required R authenticating(),
- required R authenticated(
- T user
- required R error(
- Object error,
- StackTrace stackTrace
Exhaustively pattern-matches all four auth states.
Implementation
R when<R>({
required R Function() unauthenticated,
required R Function() authenticating,
required R Function(T user) authenticated,
required R Function(Object error, StackTrace stackTrace) error,
}) {
final onUnauth = unauthenticated;
final onAuthng = authenticating;
final onAuthed = authenticated;
final onError = error;
return switch (this) {
AuthUnauthenticated<T>() => onUnauth(),
AuthAuthenticating<T>() => onAuthng(),
AuthAuthenticated<T>(:final user) => onAuthed(user),
AuthError<T>(:final error, :final stackTrace) => onError(
error,
stackTrace,
),
};
}