exportImage method

Future<Uint8List?> exportImage()

Generates Uint8List of the ui.Image generated by the renderImage() method. Can be converted to image file by writing as bytes.

Implementation

Future<Uint8List?> exportImage() async {
  late ui.Image _convertedImage;
  //  questo fa un mix della foto in back + l'overlay
  // final _boundary = _repaintKey.currentContext!.findRenderObject() as RenderRepaintBoundary;
  // _convertedImage = await _boundary.toImage(pixelRatio: 3);

  //a noi interessa SOLO _image (ns overlay puro)
  _convertedImage = await _renderImage();
  final byteData = await _convertedImage.toByteData(format: ui.ImageByteFormat.png);
  return byteData?.buffer.asUint8List();
}