gpt4 book ai didi

android - Flutter:无法加载 Assets 图像提供者:AssetImage(bundle:null,名称: "assets/images/rose.jpg")

转载 作者:行者123 更新时间:2023-12-04 23:54:14 32 4
gpt4 key购买 nike

我无法将图像作为背景上传到堆栈,我已在 Assets 文件夹中添加图像并将其添加到 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)
代码:
  return new Scaffold(
backgroundColor: Colors.greenAccent,

body: new Stack(
children: [
new Image(
image: new AssetImage("assets/images/rose.jpg"),
fit: BoxFit.cover,
),
],
),

);
My Asset folder

最佳答案

运行flutter clean并再次运行。

关于android - Flutter:无法加载 Assets 图像提供者:AssetImage(bundle:null,名称: "assets/images/rose.jpg"),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/66085411/

32 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com