Flutter 颤振错误图像:无法加载资源
我试着让Flatter酒吧得到,尝试了几种方法来添加图像 我的名字叫yamlFlutter 颤振错误图像:无法加载资源,flutter,dart,Flutter,Dart,我试着让Flatter酒吧得到,尝试了几种方法来添加图像 我的名字叫yaml flutter: uses-material-design: true assets: - assets/images/ main.dart中的特殊代码 decoration: new BoxDecoration( image: DecorationImage( image: AssetImage('assets/image
flutter:
uses-material-design: true
assets:
- assets/images/
main.dart中的特殊代码
decoration: new BoxDecoration(
image: DecorationImage(
image: AssetImage('assets/images/thermo.png'),
fit: BoxFit.fill,
),
color: Color.fromRGBO(78, 144, 30, 1),
borderRadius: new BorderRadius.only(
topLeft: const Radius.circular(30.0),
topRight: const Radius.circular(30.0),
bottomLeft: const Radius.circular(30.0),
bottomRight: const Radius.circular(30.0),
)
),
调试控制台
════════ Exception caught by image resource service ════════════════════════════
The following assertion was thrown resolving an image codec:
Unable to load asset: assets/images/thermo.png
When the exception was thrown, this was the stack
#0 PlatformAssetBundle.load
package:flutter/…/services/asset_bundle.dart:225
<asynchronous suspension>
#1 AssetBundleImageProvider._loadAsync
package:flutter/…/painting/image_provider.dart:668
#2 AssetBundleImageProvider.load
package:flutter/…/painting/image_provider.dart:651
════════ 图像资源服务捕获到异常════════════════════════════
解析图像编解码器时引发了以下断言:
无法加载资源:assets/images/thermo.png
当抛出异常时,这是堆栈
#0平台组装绑定。加载
套餐:颤振/../services/asset_bundle.省道:225
缩进(空格)在pubspec.yaml文件中非常重要。你的问题与此有关。您可以这样修复它:
flutter:
uses-material-design: true
assets:
- assets/images/
YAML对空格敏感。检查你的缩进。谢谢!现在工作