im trying to get an Image from my firebase storage and add it in my Code.
My Code:
loadImage() async{
//current user id
final _userID = FirebaseAuth.instance.currentUser!.uid;
//collect the image name
DocumentSnapshot variable = await FirebaseFirestore.instance.
collection('data_user').
doc('user').
collection('personal_data').
doc(_userID).
get();
//a list of images names (i need only one)
var _file_name = variable['path_profile_image'];
//select the image url
Reference ref = FirebaseStorage.instance.ref().child("images/user/profile_images/${_userID}").child(_file_name[0]);
//get image url from firebase storage
var url = await ref.getDownloadURL();
//logging
print('Image Url: ' + url.toString());
//return image.network
return Image.network(url.toString());
}
I have create for each user a document. In the document i save the image name. See data base:
To get the profile picture i take the image name and go to firebase storage. Then i take the image which has the same image name as the image in firebase database.
Firebase storage:
How i can take an image from firebase storage and show it in my app?