Home > OS >  Is it possible to store username in FirebaseAuth.instance.currentUser with Firebase for Flutter?
Is it possible to store username in FirebaseAuth.instance.currentUser with Firebase for Flutter?

Time:01-20

I want to store user information. Right now I created a collection Users with an email, an username and a profile image. I can get all this data using a method Future<CloudUser> getUserDetails({required String userId});. Is it possible to store the username in the class FirebaseAuth.instance.currentUser? so I don't have to use the method getUserDetails everytime I want to get the username. I am using flutter and firestore.

CodePudding user response:

Is it possible to store the username in the class FirebaseAuth.instance.currentUser?

You can store the username in the displayName property of the User class.

You can set this value by modifying the user object with the updateDisplayName() method, as shown here in the doc.

  • Related