Reputation: 974
I am trying to pick an asset image -> base64image String -> Display it But it is not working as expected. My code is as follows:
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;
The ShowImage part:
@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
),
),...........
I get the folowing error:
type 'Image' is not a subtype of type 'ImageProvider<dynamic>'
Upvotes: 1
Views: 390
Reputation: 974
Ok found the answer.
I should use MemoryImage and NOT Image.memory!
Upvotes: 1