I\'m having issues setting up signing up with an email and password using Flutter. I got it to sign the new user in and it saves their Firebase authentication info but it do
go to payment.dart and enable the option of the checkout page
and disable the native option
currentUser
is null because you didn't initialize the class. For example:
saveUserInfoToFireStore() async {
currentUser = User(); //initialize
preferences = await SharedPreferences.getInstance();
DocumentSnapshot documentSnapshot = await usersReference.document(currentUser.id).get();
Of course the above code still wont work, because id
is equal to null. If the document id in your database is equal to the user uid, then do the following:
User loggedInUser;
saveUserInfoToFireStore() async {
var user = FirebaseAuth.instance.currentUser();
loggedInUser = User(id : user.uid);
preferences = await SharedPreferences.getInstance();
DocumentSnapshot documentSnapshot = await usersReference.document(loggedInUser.id).get();
So here you get the uid
of the user from Firebase Authentication and then since you are using optional named parameter, you can initialize the User
class with the id
property and use it inside the document()
method.