从Firestore在Flutter中加载多个图像。

huangapple go评论115阅读模式
英文:

Load multiple images from Firestore in Flutter

问题

假设我有一个Firebase集合,其中包含一些记录如下:

Product { name : "Speaker", image_name: "spkr01.png" }

此外,名为**(spkr01.png)**的图像已经存储在Firestore中。

我已经从数据库加载了所有产品,那么如何在ListView中加载每个产品对应的图像呢?

我尝试了一些解决方案,但没有一个能让它工作,甚至一个图像对我都无法工作。

英文:

Assuming that i have firebase collection within i have some records like this :

Product
{
name : "Speaker",
image_name: "spkr01.png"
}

in addition, the image with name (spkr01.png) already stored in firestore,

i already loaded all products from database, so how to load every image for corresponds products in listview

i have tried some solution, but i didn't make it to work even one image it doesn't work for me.

答案1

得分: 0

最好存储图像URL而不是图像名称。而且,我假设你是指将图像上传到Firebase存储。在上传到存储后获取图像URL,并将图像URL写入产品的image_url参数。

英文:

It's better to store image URL instead of image name. And, I assume you meant your uploaded to Firebase Storage. Get image url after you upload to Storage and write image URL to product's image_url parameter.

huangapple
  • 本文由 发表于 2023年6月18日 17:30:28
  • 转载请务必保留本文链接:https://go.coder-hub.com/76499864.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定