gpt4 book ai didi

flutter - 抖动图像转换

转载 作者:行者123 更新时间:2023-12-03 03:38:33 26 4
gpt4 key购买 nike

我正在尝试选择 Assets 图像-> base64image字符串->显示它
但是它没有按预期工作。我的代码如下:

ImagePickPart:

ByteData bytes = await rootBundle.load(_images[_ran.nextInt(_images.length)]);
String asBase64 = base64Encode((bytes.buffer.asUint8List()).cast<int>());
Site site= Site();
site.image = asBase64;

ShowImage部分:
 @override
Widget build(BuildContext context) {
return Container(
margin: EdgeInsets.all(8.0),
decoration: BoxDecoration(
boxShadow: [BoxShadow(
color: Colors.grey[500],
offset:Offset(0.0,0.0),
blurRadius: 5.0,
spreadRadius: 0.0,
)],
borderRadius: BorderRadius.only(topLeft:Radius.circular(00.0),topRight:Radius.elliptical(75.0, 75.0)),
image : DecorationImage(
image: site.image!=null? Image.memory(base64Decode(site.image)):AssetImage('images/1024LowPoly.png'),
fit: BoxFit.cover
),
),...........

我收到以下错误:
type 'Image' is not a subtype of type 'ImageProvider<dynamic>'

最佳答案

确定找到了答案。

我应该使用MemoryImage而不是Image.memory!

关于flutter - 抖动图像转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58991606/

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