I am looking to upload a image file into firebase storage. But it doesn’t show any images on the firebase storage when I refresh. I am using flutter for web and uploading the image from my mac desktop. Here is the code snippet:
IconButton(
color:
const Color.fromARGB(255, 250, 250, 250),
onPressed: () async {
ImagePicker imagePicker = ImagePicker();
String uniqueFileName = DateTime.now()
.millisecondsSinceEpoch
.toString();
XFile? file = await imagePicker.pickImage(
source: ImageSource.gallery);
if (file == null) return;
Reference referenceRoot =
FirebaseStorage.instance.ref();
Reference referenceDirectory =
referenceRoot.child('UserImages');
Reference referenceImageToUpload =
referenceDirectory
.child(uniqueFileName);
try {
await referenceImageToUpload
.putFile(File(file.path));
imageUrl = await referenceImageToUpload
.getDownloadURL();
debugPrint('ImageUrlReceived');
} catch (error) {}
},
icon: const Icon(Icons.edit)),