如何解决未显示颤动图像
body: Container(
decoration: Boxdecoration(
image: decorationImage(
image: Assetimage("loginBackground"),),)
),
但是,当我运行它时,它会打开一个带有一些 Flutters 代码的新编辑器,并且一行突出显示为黄色,我认为这意味着一个断点(如果我错了,请纠正我)。文件名是“image_provider.dart”,这是相关代码(我已经指出了突出显示的行):
@protected
Future<ui.Codec> _loadAsync(AssetBundleImageKey key,DecoderCallback decode) async {
ByteData? data;
// Hot reload/restart Could change whether an asset bundle or key in a
// bundle are available,or if it is a network backed bundle.
try {
data = await key.bundle.load(key.name);
} on FlutterError {
PaintingBinding.instance!.imageCache!.evict(key);
rethrow; // THIS IS THE HIGHLIGHTED LINE
}
// `key.bundle.load` has a non-nullable return type,but might be null when
// running with weak checking,so we need to null check it anyway (and
// ignore the warning that the null-handling logic is dead code).
if (data == null) { // ignore: dead_code
PaintingBinding.instance!.imageCache!.evict(key);
throw StateError('Unable to read data');
}
return await decode(data.buffer.asUint8List());
}
}
我不知道这是什么意思,所以任何帮助将不胜感激。 这是图像(滚动):
(抱歉太大了) 如果您需要更多详细信息,请发表评论:)
解决方法
在 assetImage
中,synatx 通常是这样的:
image: AssetImage("images/loginBackground.png")
此外,如果您没有在 pubspec.yaml 中通过在您的资产部分执行此操作来启用您的资产:
assets:
- images/
还有一点错误代码会有所帮助
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。