我正在尝试选择资产图像-> base64image 字符串-> 显示它但它没有按预期工作。我的代码如下:
图像选择部分:
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>'