Home > front end >  Use Firebase Storage and Cloud Firestore "at the same time"
Use Firebase Storage and Cloud Firestore "at the same time"

Time:11-13

I have a simple code with a ListView.builder connected to Cloud Firestore. Each List item looks like this:

enter image description here

As you can see, there's a leading image. Until now, it is storage in a assets/images/ folder. I want to add the images to Firebase Storage, so that each list item have a specific and unique image. The solutions I've seen to retrieve images uses FutureBuilder and stream, but I already use a StreamBuilder and stream for the Cloud Firestore.

I just want some light on what I can/need to do, there's no need of code. Can't think of a way to do it.

CodePudding user response:

It is possible (and in fact, quite common) to nest StreamBuilders and FutureBuilders.

For example, if you have documents in Firestore, and each of those contains the URL of an image in Cloud Storage, you'll typically end up with:

  1. a StreamBuilder for the Firestore documents, so that you can keep the UI in sync with the database.
  2. a separate FutureBuilder for each image.

Since these are separate load operations, you need a separate *Builder for each of them. That is not a problem, and in fact working-as-intended.

  • Related