Sow*_*amy 4 android flutter flutter-test flutter-layout flutter-animation
我无法将图像作为背景上传到堆栈,我已将图像添加到资产文件夹中并将其添加到 pubspec.yaml 并向我显示该错误:
Exception caught by image resource service.
The following assertion was thrown resolving an image codec:
Unable to load asset: assets/images/rose.jpg
When the exception was thrown, this was the stack:
#0 PlatformAssetBundle.load (package:flutter/src/services/asset_bundle.dart:225:7)
<asynchronous suspension>
#1 AssetBundleImageProvider._loadAsync (package:flutter/src/painting/image_provider.dart:668:31)
#2 AssetBundleImageProvider.load (package:flutter/src/painting/image_provider.dart:651:14)
#3 ImageProvider.resolveStreamForKey.<anonymous closure> (package:flutter/src/painting/image_provider.dart:504:13)
...
Image provider: AssetImage(bundle: null, name: "assets/images/rose.jpg")
Image key: AssetBundleImageKey(bundle: PlatformAssetBundle#dea48(), name: "assets/images/rose.jpg", scale: 1.0)
Run Code Online (Sandbox Code Playgroud)
代码:
return new Scaffold(
backgroundColor: Colors.greenAccent,
body: new Stack(
children: [
new Image(
image: new AssetImage("assets/images/rose.jpg"),
fit: BoxFit.cover,
),
],
),
);
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
21268 次 |
| 最近记录: |