无法加载资源:图像
我有这个资产图像代码,
Image.asset(
'${listPic[1]}',
),
图像位于列表中最终列表<图像> listPic= [ Image.asset('assets/images/pic1.jpg'), Image.asset('assets/images/pic2.jpg'), ];
我知道 pubsec 有效,因为当我像这样直接输入图像位置时,
Image.asset(
'assets/images/pic1.jpg',
),
图像就会显示, 列表或 Image.asset() 是否有问题 我尝试在 ${listPic[0]} 之后使用 .toString 它没有做任何事情而是说不必要的字符串插值。
给出这个错误
The following assertion was thrown resolving an image codec: Unable to load asset: Image(image: AssetImage(bundle: null, name: "assets/images/pic1.jpg"), frameBuilder: null, loadingBuilder: null, alignment: Alignment.center, this.excludeFromSemantics: false, filterQuality: low)
I have this code for asset image
Image.asset(
'${listPic[1]}',
),
the images are located in a Listfinal List<Image> listPic= <Image>[ Image.asset('assets/images/pic1.jpg'), Image.asset('assets/images/pic2.jpg'), ];
I know the pubsec works, because when I directly type the image location like this
Image.asset(
'assets/images/pic1.jpg',
),
the image is displayed,
Is there something wrong with the list or Image.asset()
I have tried using .toString after the ${listPic[0]} it didn't do anything instead said unnecessary string interpolation.
gives this error
The following assertion was thrown resolving an image codec: Unable to load asset: Image(image: AssetImage(bundle: null, name: "assets/images/pic1.jpg"), frameBuilder: null, loadingBuilder: null, alignment: Alignment.center, this.excludeFromSemantics: false, filterQuality: low)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您声明的列表是
list&lt; image&gt;
类型,但您正在使用它,就好像是list&lt; string&gt;
。而是尝试一下:
The list you declared is a
List<Image>
type, but you are using it as if it's aList<String>
.Try this instead: