Image provider: AssetImage(bundle: null, name: “assets/images/hot.png”) Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#9d9f7(), name: “assets/images/hot.png”, scale: 1)
当使用了图像 并且在所有地方都是正确的时候
这个错误信息表明找不到 assets/images/hot.png
文件。可以检查以下几点来解决问题:
assets/images/hot.png
文件实际存在于你的项目目录中。pubspec.yaml
: 确保在 pubspec.yaml
文件中正确声明了资产路径,并且缩进没有问题。
yaml
flutter: assets: - assets/images/hot.pngr
)或完全重启应用(R
)以应用新的资产配置。这个时候,哪怕是调试也是直接重启就行了,如果不确认问题,可以在图像加载前加入判断:
'assets/images/hot.png', // 设置图片路径
fit: BoxFit.cover,
errorBuilder: (BuildContext context, Object exception, StackTrace? stackTrace) {
return Text('Failed to load image');
},
如果提示是这样的问题,那么就确定是了。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。
原创声明:本文系作者授权腾讯云开发者社区发表,未经许可,不得转载。
如有侵权,请联系 cloudcommunity@tencent.com 删除。