Populate current user from Firebase

Viewed 21

I am following this FilledStacks' Youtube playlist and tried to update it based on the latest Firebase changes. But after adding the _populateCurrentUser logic logic the app froze on the startup screen. I was expecting to get the user info and get past the startup screen and navigate to home. It doesn't throw an error, it just shows the startup screen. I have tried to double-check my code and also researched it. It returns the correct uid from Firestore but not sure why it isn't populating the user. Here is my code.

//1
var user = await _firebaseAuth.currentUser;

//2
await _populateCurrentUser(user!);

//3
Future _populateCurrentUser(User user) async {
  _currentUser = await _firestoreService.getUser(user.uid);
}

//4
var userData = await _usersCollectionReference.doc(uid).get();

//5
UserAccountModel.fromMap(userData.data as Map<String, dynamic>);

//6
factory UserAccountModel.fromMap(Map<String, dynamic> json) =>
   UserAccountModel(
      id: json["id"] ,
      fullName: json["fullName"],
      email: json["email"],
);
0 Answers
Related