如果我要访问的资产映像无法加载,我想要后备资产图像。
如果此代码: image(image:AssetImage('images/myimage.png'))
引发错误,我想显示一个后备,例如 image image(image:aSsetImage:'' images/halldackimage.png'))'
。
我阅读 /a>,但这对我不起作用。使用自定义资产捆绑包,即使现有图像也没有加载。
I want a fallback asset image if the asset image I'm trying to access can't be loaded.
If this code: Image(image: AssetImage('images/myImage.png'))
throws an error, I would like to display a fallback, for example Image(image: AssetImage('images/fallbackImage.png'))'
.
I read through this article on medium but that didn't work for me. With the custom Asset Bundle, not even the existing images got loaded.
发布评论
评论(1)
您可以使用
errorbuilder
属性:在您的情况下(null Safe):
这是一个完整的示例,直接从文档:
You can use the
errorBuilder
property:In your case (null safe):
Here is a complete example taken straight from the documentation: