尝试在颤动中加载图像但无法做到这一点,出现以下错误
I/颤振(3214):══╡图像资源服务发现异常╞══════════════════════╕═══════════════ ═══════════════════ I/flutter(3214):抛出以下断言解析图像编解码器:I/flutter(3214):无法加载资产:资产/ test.jpg I/flutter (3214): I/flutter (3214): 当异常被抛出时,这是堆栈: I/flutter (3214): #0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle .dart:221:7) I/flutter (3214): I/flutter (3214): #1
AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:429:44) I/flutter (3214):我/颤动(3214):#2
AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:414:14) I/flutter (3214): #3 ImageProvider.resolve.. (package:flutter/src/painting/image_provider.dart:267:86 ) I/flutter (3214): #4 ImageCache.putIfAbsent (package:flutter/src/painting/image_cache.dart:143:20) I/flutter (3214): #5 ImageProvider.resolve。(包:flutter/src/painting/image_provider.dart:267:63)I/flutter(3214):(从包 dart:async 中省略了 8 帧)I/flutter(3214):I/flutter(3214):图像提供程序: AssetImage(bundle: null, name: "assets/test.jpg") I/flutter (3214): Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#81de5(), name: "assets/test.jpg", scale: I /颤动(3214):1.0)我/颤动(3214):
主要.dart
lass MyApp extends StatelessWidget {
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('EasyList'),
),
body: Card(child: Column(children: < Widget > [
Image.asset('assets/test.jpg'),
],),),
),
);
}
}
发布规范.yaml
flutter:
uses-material-design: true
assets:
- assets/test.jpg