【发布时间】:2021-08-04 13:01:51
【问题描述】:
我正在尝试将 AssetImage 加载到 CircleAvatar 中,但这对我来说失败并出现以下错误:
======== Exception caught by image resource service ================================================
The following assertion was thrown resolving an image codec:
Unable to load asset: images/legozombie.png
When the exception was thrown, this was the stack:
#0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:227:7)
<asynchronous suspension>
#1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:667:14)
<asynchronous suspension>
Image provider: AssetImage(bundle: null, name: "images/legozombie.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#fe462(), name: "images/legozombie.png", scale: 1.0)
====================================================================================================
到目前为止,我已经完成了以下工作:
- 创建了一个名为 images 的文件夹,并在我的 Android Studio Flutter 项目中添加了文件 legozombie.png。
- 更新了 pubspec.yaml 以包含资产。
- 运行 pub.get
- 运行获取依赖项。
下图显示了我的文件夹结构、pubspec.yaml 文件和我的代码。
如果有人能指出我做错了什么,我将不胜感激。我可以说使用 NetworkImage,一切正常。
非常感谢任何帮助。
【问题讨论】:
-
嗯,这对我有帮助!我只需要重新启动调试会话。
标签: flutter