我试图将图像加载到滚动条中,但是每次由于错误而没有加载图像时:
Exception caught by image resource service The following assertion was thrown resolving an image codec:
Unable to load asset: assets/images/jorge.png
引发异常时,这是堆栈:
0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7)
1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:464:44)
2 AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:449:14)
...
Image provider: AssetImage(bundle: null, name: "assets/images/jorge.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#dd41f(), name: "assets/images/jorge.png", scale: 1.0)
(2)图片资源服务捕获的异常
Unable to load asset: assets/images/heitor.png
(3)图片资源服务捕获的异常
Unable to load asset: assets/images/john.png
I/chatty ( 8763): uid=10206(com.festapp.flutter_app_fest) identical 5 lines
E/AccessibilityBridge( 8763): VirtualView node must not be the root node.
flutter clean was used, besides exchanging images
final User currentUser = User(
id: 0,
name: 'Current User',
imageUrl: 'assets/images/greg.png'
);
//usuários
final User Jorge = User(
id: 1,
name: 'Jorge',
imageUrl: 'assets/images/jorge.png'
);
final User John= User(
id: 2,
name: 'John',
imageUrl: 'assets/images/john.png'
);
final User Heitor = User(
id: 3,
name: 'Heitor',
imageUrl: 'assets/images/heitor.png'
); 最终用户Gui =用户( 编号:4 名称:'Gui', imageUrl:“ assets / images / heitor.png” );
和图像用于:
return Padding(
padding: EdgeInsets.all(10.0),
child: Column(
children: <Widget>[
CircleAvatar(
radius: 35.0,
backgroundImage: AssetImage(favorites[index].imageUrl),
),
SizedBox(
height: 6.0,
),
Text(favorites[index].name, style: TextStyle(
color: Colors.blueGrey,
fontSize: 16.0,
fontWeight: FontWeight.w600,
),
),
],
),
);
图像资源服务捕获的异常
抛出了以下断言来解析图像编解码器:
Unable to load asset: assets/images/jorge.png
引发异常时,这是堆栈:
0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:221:7)
1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:464:44)
2 AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:449:14)
...
Image provider: AssetImage(bundle: null, name: "assets/images/jorge.png")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#dd41f(), name: "assets/images/jorge.png", scale: 1.0)
(2)图片资源服务捕获的异常
Unable to load asset: assets/images/heitor.png
(3)图片资源服务捕获的异常
Unable to load asset: assets/images/john.png
答案 0 :(得分:0)
这些图像文件似乎不在您的项目中:
assets/images/jorge.png
assets/images/john.png
assets/images/heitor.png
确保您正在执行以下操作:
assets/images/
pubspec.yaml
中指定图像flutter packages get
/点击Packages get
pubspec.yaml
/从任何镖文件中点击Get dependencies
。Image.asset()
或AssetImage()
来显示它们。