Search code examples
flutterdartid3

How to display an image from AttachedPicture | Flutter


I'm trying to display a cover image from an MP3 file. I'm getting the ID3 tags from https://github.com/NiKoTron/dart-tags.

My Code:

TagProcessor tp = TagProcessor();
tp.getTagsFromByteArray(bytes).then((l) async {

  AttachedPicture picture = l[1].tags['picture']['Cover (front)'];

  log(picture.toString()); // ->[log] {mime:image/png, description:, bitmap: iVBORw0KGgoAAAANSUhEUgAABLAAAASw...}
});

The mime: image/png is just a string, so I don't exactly know how to get the image.


Solution

  • AttachedPicture has property imageData which is of type List<int>.

    You could use Image.memory to display imageData by using Uint8List.fromList.

    import 'dart:typed_data';
    
    Image.memory(
      Uint8List.fromList(imageData),
    );