首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >Flutter无法加载资源:但目录不存在

Flutter无法加载资源:但目录不存在
EN

Stack Overflow用户
提问于 2020-08-12 23:32:53
回答 1查看 462关注 0票数 0

flutter抛出了这些错误,但他找不到的图像并不存在!确实存在的图像位于assets/ images /文件夹中,并且具有其他(普通)名称。我在pubspec.yaml中正确地导入了它们,对于这个奇怪的问题有什么解决方案?

代码语言:javascript
运行
复制
══╡ EXCEPTION CAUGHT BY IMAGE RESOURCE SERVICE ╞════════════════════════════════════════════════════
The following assertion was thrown resolving an image codec:
Unable to load asset: assets/images/v.png

When the exception was thrown, this was the stack:
#0      PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:223:7)
<asynchronous suspension>
#1      AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:669:31)
#2      AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:652:14)
#3      ImageProvider.resolveStreamForKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:505:13)
#4      ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:360:22)
#5      ImageProvider.resolveStreamForKey (package:flutter/src/painting/image_provider.dart:503:80)
#6      ScrollAwareImageProvider.resolveStreamForKey (package:flutter/src/widgets/scroll_aware_image_provider.dart:108:19)
#7      ImageProvider.resolve.<anonymous closure> (package:flutter/src/painting/image_provider.dart:334:9)
#8      ImageProvider._createErrorHandlerAndKey.<anonymous closure>.<anonymous closure> (package:flutter/src/painting/image_provider.dart:464:26)
(elided 13 frames from dart:async)

Image provider: AssetImage(bundle: null, name: "assets/images/v.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#8dc86(), name: "assets/images/v.png",
  scale: 1.0)
════════════════════════════════════════════════════════════════════════════════════════════════════

════════ Exception caught by image resource service ════════════════════════════════════════════════
The following assertion was thrown resolving an image codec:
Unable to load asset: assets/images/v.png

When the exception was thrown, this was the stack: 
#0      PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:223:7)
<asynchronous suspension>
#1      AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:669:31)
#2      AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:652:14)
#3      ImageProvider.resolveStreamForKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:505:13)
...
Image provider: AssetImage(bundle: null, name: "assets/images/v.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#8dc86(), name: "assets/images/v.png", scale: 1.0)
════════════════════════════════════════════════════════════════════════════════════════════════════

Another exception was thrown: Unable to load asset: assets/images/e.png

════════ Exception caught by image resource service ════════════════════════════════════════════════
Unable to load asset: assets/images/e.png
════════════════════════════════════════════════════════════════════════════════════════════════════

Another exception was thrown: Unable to load asset: assets/images/h.png

════════ Exception caught by image resource service ════════════════════════════════════════════════
Unable to load asset: assets/images/h.png
════════════════════════════════════════════════════════════════════════════════════════════════════

Another exception was thrown: Unable to load asset: assets/images/i.png

════════ Exception caught by image resource service ════════════════════════════════════════════════
Unable to load asset: assets/images/i.png
════════════════════════════════════════════════════════════════════════════════════════════════════
EN

回答 1

Stack Overflow用户

发布于 2020-08-12 23:53:28

代码语言:javascript
运行
复制
 you can go to pubspec.yaml and give folder path there
 assets:
- assets/images/

Don't need to give the name of image just give folder path then

再次运行应用程序

票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/63379931

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档