【发布时间】:2021-08-17 19:43:32
【问题描述】:
错误:
======= 图像资源服务捕获的异常 ================================== =============== 抛出以下断言来解析图像编解码器: 无法加载资产:images/google-logo.png
当异常被抛出时,这是堆栈: #0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:227:7) #1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:667:14) 图片提供者:AssetImage(bundle: null, name: "images/google-logo.png") 图片键:AssetBundleImageKey(bundle: PlatformAssetBundle#36c1f(), name: "images/google-logo.png", scale: 1.0)
我的“pubspec.yaml”文件:
'''flutter:
uses-material-design: true
assets:
- images/facebook-logo.png
- images/google-logo.png '''
我正在使用以下代码将图像加载到页面中: IN '登录 page.dart' 文件:
'''CustomRaisedButton(
child: Image.asset('images/google-logo.png'),
color: Colors.white,
onPressed: () {},
),'''
【问题讨论】:
-
您是否在
pubspec.yaml中添加了资产文件夹?你可以关注这个话题stackoverflow.com/questions/50903106/… -
@ChiragBargoojar 我确实在“pubspec.yaml”文件中添加了资产文件夹。
-
能否分享您的
pubspec.yaml以及您创建资产文件夹的位置?
标签: flutter android-studio dart pubspec