when<T> method
T
when<T>({
- required T success(
- UserInfo userInfo,
- TokenResponse tokens
- required T failure(
- FrappeAuthException error
Executes appropriate callback based on result
Implementation
T when<T>({
required T Function(UserInfo userInfo, TokenResponse tokens) success,
required T Function(FrappeAuthException error) failure,
}) {
if (this.success && userInfo != null && tokens != null) {
return success(userInfo!, tokens!);
} else if (error != null) {
return failure(error!);
} else {
throw StateError('AuthResult is in an invalid state');
}
}