toPNG method
Converts the picture to a PNG and returns the bytes of the PNG.
This might throw a FlutterError, if flutter is not able to convert the intermediate Image to a PNG.
Implementation
Future<Uint8List> toPNG() async {
Image image = await toImage();
ByteData? data = await image.toByteData(format: ImageByteFormat.png);
if (data != null) {
return data.buffer.asUint8List();
} else {
throw new FlutterError('Flutter failed to convert an Image to bytes!');
}
}