Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there any feature to add/update firebase user name and photo url in flutter?

Is there anyway to add/update firebase user name and photo url in flutter like we have UserProfileChangeRqeust() in native android?

like image 238
Muhammad Faizan Avatar asked Sep 10 '19 11:09

Muhammad Faizan


People also ask

Is Firebase good for Flutter?

Firebase is a great backend solution for anyone that wants to use authentication, databases, cloud functions, ads and countless other features within an app luckily for us, Flutter has official support for Firebase with the FlutterFire set of libraries.

Why Firebase is best for Flutter?

The Firebase real-time database, ready-made authentication options along with the Flutter in-built widgets and a single code for Android and iOS make the whole healthcare software development process faster while maintaining the solution's safety and performance.


2 Answers

Yes, there is.

After you have received FirebaseUser, you can call the updateProfile() method on the object to provide the new details.This method will take an input of type UserUpdateInfo.

For eg.,

FirebaseUser user = await _auth.currentUser();

UserUpdateInfo userUpdateInfo = UserUpdateInfo();

userUpdateInfo.displayName = 'Ayush';
userUpdateInfo.photoUrl = '<my photo url>';

await user.updateProfile(userUpdateInfo);
like image 165
Ayush Shekhar Avatar answered Oct 17 '22 15:10

Ayush Shekhar


UPDATE 2021, FEB

This is the updated way for changing the users displayName and photoURL

 void updateUserInfo() {
   var user = FirebaseAuth.instance.currentUser;
   user.updateProfile(displayName: "Abel", photoURL: "photoPath").then((value){
      print("Profile has been changed successfully");
      //DO Other compilation here if you want to like setting the state of the app
   }).catchError((e){
      print("There was an error updating profile");
   });
 }

you can read more about this on the official firebase flutter doc. here

like image 21
Abel Tilahun Avatar answered Oct 17 '22 15:10

Abel Tilahun