BloomAuth<U> constructor
BloomAuth<U> ({})
Creates a BloomAuth session manager.
If autoProvide is true, registers this instance into the global DI container.
Implementation
BloomAuth({
this.storage,
U Function(Map<String, dynamic> json)? fromJson,
U Function(Map<String, dynamic> json)? userDeserializer,
Map<String, dynamic> Function(U user)? toJson,
Map<String, dynamic> Function(U user)? userSerializer,
this.sessionKey = 'bloom_auth_session',
bool autoProvide = false,
}) : fromJson = fromJson ?? userDeserializer,
toJson = toJson ?? userSerializer {
_currentUser = signal<U?>(null, debugLabel: 'auth.currentUser');
_token = signal<String?>(null, debugLabel: 'auth.token');
_isAuthenticated = computed<bool>(
() => _currentUser.value != null && _token.value != null && _token.value!.isNotEmpty,
debugLabel: 'auth.isAuthenticated',
);
if (autoProvide) {
globalContainer.provideValue<BloomAuthBase>(this);
}
}