Flutter, dart:io - convert Uint8List (from websocket) to a jpeg file I can draw
First try using Uint8List
directly with Image.memory
widget.
example:
new Image.memory(binaryIntList);
If that doesn't work as expected.
You can use the image
dart package to first decode the bytes to Image
object and the encode it to the format you wish.
example:
import 'package:image/image.dart' as I; //So that this does not conflict with the Image widget
then
I.Image _img = I.decodeImage(binaryIntList);
_img = I.encodeJpg(_img);
then use it as
new Image.memory(_img.getBytes());
Hope that helped!