AuthenticationBloc constructor
AuthenticationBloc({
- required AuthenticationRepository repository,
Implementation
AuthenticationBloc({
required this.repository,
}) : super(AuthInitial()) {
unawaited(checkAuthStatus());
exceptionsStream.listen(
(final AuthException event) {
if (event.exception is AuthenticationExpired) {
_onAuthTokenRefreshFail(
isOnStartup: event.isOnStartup,
);
}
},
);
on<AuthenticationEvent>(
(
final AuthenticationEvent event,
final Emitter<AuthenticationState> emit,
) async {
try {
await _mapEventToState(event, emit);
event.onComplete?.call();
} catch (e) {
// add(const AuthErrorEvent());
log(
'AuthBloc Exception',
error: e,
);
event.onError?.call(e);
rethrow;
}
},
);
}