Reputation: 35
I am trying to built a profile picture and also using a firestore. I can not update the selected profile picture on the screen I need to hot refresh for it. The question is how can I update it and display it on the screen when the user select another profile picture
final user = FirebaseAuth.instance.currentUser!;
This is my image picker:
Future uploadProfilePicture() async {
final image = await ImagePicker().pickImage(
source: ImageSource.gallery,
maxWidth: 500,
maxHeight: 500,
);
Reference ref = FirebaseStorage.instance.ref().child("profilePic.jpg");
await ref.putFile(File(image!.path));
ref.getDownloadURL().then((value) {
setState(() {
imageURL = value;
user.updatePhotoURL(value);
});
});
}
This is how I display it on the screen:
GestureDetector(
onTap: () {
uploadProfilePicture();
},
child: Padding(
padding: const EdgeInsets.all(8),
child: ProfilePicture(
name: user.displayName!,
radius: 40,
fontsize: 20,
img: user.photoURL,
)),
)
Upvotes: 1
Views: 94