【问题标题】:CircleAvatar - backgroundImage AssetImage failing to loadCircleAvatar - backgroundImage AssetImage 无法加载
【发布时间】: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)
====================================================================================================

到目前为止,我已经完成了以下工作:

  1. 创建了一个名为 images 的文件夹,并在我的 Android Studio Flutter 项目中添加了文件 legozombie.png
  2. 更新了 pubspec.yaml 以包含资产。
  3. 运行 pub.get
  4. 运行获取依赖项。

下图显示了我的文件夹结构、pubspec.yaml 文件和我的代码。

如果有人能指出我做错了什么,我将不胜感激。我可以说使用 NetworkImage,一切正常。

非常感谢任何帮助。

【问题讨论】:

  • 嗯,这对我有帮助!我只需要重新启动调试会话。

标签: flutter


【解决方案1】:

好吧,现在感觉很愚蠢,但是在我杀死 iOS 模拟器然后重新启动它和我的应用程序后,它运行良好。

因为我添加了一个新资源,我不得不停止并重新启动应用程序,而不是热加载它。

【讨论】:

猜你喜欢
  • 2018-09-29
  • 2020-08-22
  • 2020-09-19
  • 2021-05-11
  • 1970-01-01
  • 2018-08-26
  • 2019-10-31
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多