Is there anyway to add/update firebase user name and photo url in flutter like we have UserProfileChangeRqeust()
in native android?
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.
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.
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);
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With