imgImageToUiImage method

Future<Image> imgImageToUiImage(
  1. Image image
)

Implementation

Future<ui.Image> imgImageToUiImage(img.Image image) async {
  //https://medium.com/@ys.commerciale/process-and-show-an-image-in-flutter-aebb0054ce94
  ui.ImmutableBuffer buffer = await ui.ImmutableBuffer.fromUint8List(image.getBytes());
  ui.ImageDescriptor id = ui.ImageDescriptor.raw(buffer, height: image.height, width: image.width, pixelFormat: ui.PixelFormat.rgba8888);
  ui.Codec codec = await id.instantiateCodec(targetHeight: image.height, targetWidth: image.width);
  ui.FrameInfo fi = await codec.getNextFrame();
  ui.Image uiImage = fi.image;

  return uiImage;
}