当前位置:网站首页>Flutter development: error The following assertion was thrown resolving an image codec: Solution for Unable to...
Flutter development: error The following assertion was thrown resolving an image codec: Solution for Unable to...
2022-08-10 05:04:00 【Three shopkeepers 666】
Foreword
In the development of Flutter, we often encounter some strange errors, such as errors after version updates, errors if files are not imported, errors of inconsistent versions of third-party plug-ins, etc., and in recent years, Flutter has continued to improve andThe speed of updates is getting faster and faster, which requires Flutter-related developers to keep a continuous learning attitude to deal with various emergencies encountered in Flutter development.This blog post will share about the solution to the error The following assertion was thrown resolving an image codec: Unable to load asset: ... after running the Flutter project in Flutter development, record it for later reference.
Error message
After running the flutter run command in the terminal, the project console reports an error. The specific error message is as follows:
===| Exception caught by image resource service |================
The following assertion was thrown resolving an image codec:
Unable to load asset: assets/mine/mine_set.png
When the exception was thrown, this was the stack:
#0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:224:7)
#1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:675:14)
Image provider: AssetImage(bundle: null, name: "assets/mine/mine_set.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#dd41f(), name: "assets/mine/mine_set.png", scale: 1.0)
==========================================================
Another exception was thrown: Unable to load asset: assets/mine/mine_arr01.png

Analysis
Although the error reported by the terminal is so long, the key sentence is "The following assertion was thrown resolving an image codec: Unable to load asset: assets/mine/mine_set.png", because when the resource file was created, the configuration image path is not introduced in Flutter's pubspec.yaml file, otherwise it will report an error that the image resource cannot be found after running.

Solution
1. After the newly created folder mine for storing pictures in the project root directory, you need to introduce the path for storing pictures
2. Then open the pubspec.yaml file under the project root directory, and then add assets/mine to assets. The specific operations are as follows:
flutter:# The following line ensures that the Material Icons font is# included with your application, so that you can use the icons in# the material Icons class.uses-material-design: true# To add assets to your application, add an assets section, like this:assets: - assets/mine/

3. Finally, when using image resources, it is also loaded using relative paths, and the image data can be loaded through the Image component.
4. Re-run the project, no error is reported, so the problem is solved perfectly.
Note: assets: is an option under flutter, so the space reserved in front of assets: must be aligned with other options in flutter, this is the standard format, and the image will be loaded and displayed normally.
Last
The following assertion was thrown resolving an image codec: Unable to load asset: ... in the development of Flutter introduced above, after running the Flutter project, the following assertion was thrown resolving an image codec: Unable to load asset: ... The solution steps, if you encounter similar problems caused by the introduction method in the futureIt's easy to solve, especially for developers who are new to Flutter development, they should master the solution to this situation, and I won't go into details here.
The above is the whole content of this chapter. Welcome to pay attention to the WeChat public account of the three shopkeepers "Program Ape by the three shopkeepers", and the Sina Weibo of the three shopkeepers "Three shopkeepers 666", welcome to pay attention!
边栏推荐
- 元宇宙 | 你能通过图灵测试吗?
- From entry to mastery of PHPCMS imitation station, Xiaobai is enough to watch this set of courses
- Mysql CDC (2.1.1) inital snapshot database set up five concurrent degree, se
- webrtc学习--websocket服务器
- 线程(下):读写者模型\环形队列\线程池
- Stacks and Queues | Implementing Queues with Stacks | Implementing Stacks with Queues | Basic Theory and Code Principles
- curl命令介绍
- 软考考生注意!2022年下半年报名详细流程来了!
- 在vscode中屏蔽Alt热键
- FPGA工程师面试试题集锦11~20
猜你喜欢

栈与队列 | 有效的括号、删除字符串中的所有相邻元素、逆波兰表达式求值、滑动窗口的最大值、前K个高频元素 | leecode刷题笔记

告诉你如何从keil工程知道使用了多少RAM和ROM空间

文献 | 关于心理活动符号学,你知道多少?

深度梳理:防止模型过拟合的方法汇总

LeetCode 6138. 最长理想子序列 动态规划

【u-boot】u-boot驱动模型分析(02)

万字总结:分布式系统的38个知识点

2022年R2移动式压力容器充装考试题库模拟考试平台操作

#【软件STM32cubeIDE下F103配置uart3+DMA收发+简单数据解析-基础样例】

Flutter开发:报错The following assertion was thrown resolving an image codec:Unable to…的解决方法
随机推荐
FPGA工程师面试试题集锦11~20
leetcode每天5题-Day13
栈与队列 | 有效的括号、删除字符串中的所有相邻元素、逆波兰表达式求值、滑动窗口的最大值、前K个高频元素 | leecode刷题笔记
安芯电子IPO过会:年营收4亿 汪良恩兄弟持股61.6%
大佬们,mysql cdc(2.2.1跟之前的版本)从savepoint起有时出现这种情况,有没有什
暑期学前作业
如何在不同场景下选择合适的示波器探头
Thread.sleep, Thread.yield 作用解释
Unity Shader 积雪效果
2022年R2移动式压力容器充装考试题库模拟考试平台操作
RK3568处理器体验小记
用 PySpark ML 构建机器学习模型
`id` bigint(20) unsigned NOT NULL COMMENT '数据库主键',
webrtc学习--webrtc源码获取
解决“File has been changed outside the editor, reload?”提示
`id` bigint(20) unsigned NOT NULL COMMENT 'Database primary key',
盼他一切安好
在vscode中屏蔽Alt热键
leetcode每天5题-Day12
Guys, the test in the idea uses FlinkCDC SQL to read Mysql data and write it into Kafka. The code creates