Home > OS >  How to render the base64 image Data in flutter?
How to render the base64 image Data in flutter?

Time:10-20

I have converted the image to base64 data. But I want to render the data in a flutter view.

Note: The converted data I given below,

data:image/jpg;base64,/9j/4QFcRXhpZgAATU0AKgAAAAgABwEAAAQAAAABAAAPAAEQAAIAAAAJAAAAYgEBAAQAAAABAAAIcAEPAAIAAAAIAAAAa4dpAAQAAAABAAAAhwESAAMAAAABAAYAAAEyAAIAAAAUAAAAcwAAAABTTS1NNTI2QgBzYW1zdW5nADIwMjI6MTA6MTggMTE6MTU6MjgAAAekAwADAAAAAQAAAACSCgAFAAAAAQAAAOGCmgAFAAAAAQAAAOmIJwADAAAAAQAZAACSCQADAAAAAQACAACSCAAEAAAAAQAAAACCnQAFAAAAAQAAAPEAAAAAAAACFAAAAGQAAABkAAAnEAAARlAAACcQAAQBEAACAAAACQAAAS8BDwACAAAACAAAATgBEgADAAAAAQAGAAABMgACAAAAFAAAAUAAAAAAU00tTTUyNkIAc2Ftc3VuZwAyMDIyOjEwOjE4IDExOjE1OjI4AP/gABBKRklGAAEBAAABAAEAAP/

CodePudding user response:

You need to convert your Base64 String to bytes and then load the image like so:

import 'dart:convert';

final _byteImage = Base64Decoder().convert(base64Image);
Widget image = Image.memory(_byteImage)
  • Related