I'm trying to upload images to firebase storage and use that image url as metadata in firestore, however the image url is always null. (I'm assuming that the image hasn't finished uploading by the time i add it to my firestore).
this is how i get the picture:
Future<File> getPic() async { return picture = await ImagePicker.pickImage(source: ImageSource.camera); }
how i upload the picture to firebase storage:
Future<Uri> uploadPic(File image) async { StorageReference reference = _storage.ref().child("images/"); StorageUploadTask uploadTask = reference.putFile(image); Uri location = (await uploadTask.onComplete).uploadSessionUri; print('img location $location'); return location; }
how i trigger the picture to be taken by pressing a FloatingActionButton:
floatingActionButton: FloatingActionButton( onPressed: () { getPic().then((f) async => await uploadPic(f)); }),
Whenever i try to save this image uri to firestore it's always null. so what's the issue here?