3

I want to put some images that I use in my app to Firestore, and display them from there, rather than having them as assets, bundled in my app.

In order to do this, I came up with the following solution: for the item I want to display an image, I created a Firebase document, where I have a field that stores the name of the file that stores the corresponding picture:

document
- name
- description
- imageName

Then, I uploaded an image to FireStore with the same name.

When I want to display the image, I can successfully get the document via StreamBuilder, and extract the imageName property.

I also created the necessary FireStore references:

FirebaseStorage storage = new FirebaseStorage(
    storageBucket: 'gs://osszefogasaszanhuzokert.appspot.com/'
  );
StorageReference imageLink = storage.ref().child('giftShopItems').child(documentSnapshot['imageName']);

However, I can't seem to pass it to an Image.network() widget.

Is it possible to display an image the way I'd like to, or should I use a different Image provider?

1
  • So did you access your pictures from "Storage" ? If so, why did you create a field called "imgeName" under your document? I believe that field cannot reference the image stored under "Storage" right? Commented Jan 23, 2019 at 12:53

1 Answer 1

4

You need the .getDownloadURL() from the StorageReference imageLink to get the storage URL link:

final imageUrl = await imageLink.getDownloadUrl();
Image.network(imageUrl.toString());
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.