gpt4 book ai didi

flutter - 如何将我声明的变量放入 AssetImage 中

转载 作者:IT王子 更新时间:2023-10-29 07:16:51 28 4
gpt4 key购买 nike

例如,我从数据库中获取餐厅列表,我只想将图像的 url 放入 AssetImage 中,但它无法工作。我尝试使用 Image.asset,但 Imageprovider 无法放置 Image.asset。

最终餐厅列表 = _restaurant.restaurant[index];

Assets 图像(餐厅列表.imageurl); <--- 错误
Image.asset(restuarantlist.imagerurl); <--- 工作正常

知道为什么 AssetImage 不能工作吗?

最佳答案

Image 有几个构造函数。

Image, for obtaining an image from an ImageProvider.

Image.asset, for obtaining an image from an AssetBundle using a key.

Image.network, for obtaining an image from a URL.

Image.file, for obtaining an image from a File.

Image.memory, for obtaining an image from a Uint8List.



AssetImage

fetches an image from an AssetBundle,

和继承

ImageProvider < Assets 包图片 key >

Identifies an image without committing to the precise final asset.


长话短说

下载图片时使用:

Image.network(imgUrl)

关于flutter - 如何将我声明的变量放入 AssetImage 中,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/57107520/

28 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com