I want to load a image from my Firebase storage. I uploaded images such as profile photos for users with the name {users uid}.png. So when I go to users profile screen, I want to upload these images from firebase accordingly to the current user uid. What is the best way for that ?? I have a async method that sets my user properties such as final loggegInUser
and I have a async method
void getCurrentUser() async {
try {
final user = await _auth.currentUser();
if (user != null) {
loggedInUser = user;
print(loggedInUser.email);
print(uid);
}
} catch (e) {
print(e);
}
}
This method sets my global loggedInUser property then I want to load the image from firebase storage like that
CircleAvatar(
backgroundColor: Colors.black,
backgroundImage: FirebaseImage(
'gs://homeparty-68792.appspot.com/user_profile_images/${loggedInUser.uid}.png')
,
radius: 100,
),
But when I load this screen I get
ERROR TYPE Exception has occurred. NoSuchMethodError (NoSuchMethodError: The getter 'uid' was called on null. Receiver: null Tried calling: uid)
error. getCurrentUser() methods work properly it prints the e mail and password but in the build Widget It returns null. Why this is happening I need some help ???