How do I set current user using hydrated storage instead of cachedClient Like its done in bloc docs for firebase login?
They wrote in user repository:
Stream<User> get user {
return _firebaseAuth.authStateChanges().map((firebaseUser) {
final user = firebaseUser == null ? User.empty : firebaseUser.toUser;
_cache.write(key: userCacheKey, value: user);
return user;
});
}
User get currentUser {
return _cache.read<User>(key: userCacheKey) ?? User.empty;
}
I have isEmpty/isNotEmpty in my User model but in firebase there is a getter current user where cachedClient used
In my user repository i only have
Future<User> getUser({required String username, required String password}) async
and thats it
But for changing status they added new bloc where they read this current user to set authenticated/unauthenticated
This is how its done for firebase login: https://bloclibrary.dev/#/flutterfirebaselogintutorial?id=authentication-repository