createTransparentImage method

Future<Image> createTransparentImage(
  1. int width,
  2. int height
)

Implementation

Future<ui.Image> createTransparentImage(int width, int height) {
  final img.Image image = img.Image(
    width: width,
    height: height,
    numChannels: 4,
    format: img.Format.uint8, //uint8
  );
  final completer = Completer<ui.Image>();

  ui.decodeImageFromPixels(image.buffer.asUint8List(), image.width, image.height, ui.PixelFormat.rgba8888, (image) {
    return completer.complete(image);
  });
  return completer.future;
}