encodePng function
Encodes an Image object into a PNG format byte array.
Parameters:
- image: The
Imageto encode.
Returns a Future that completes with the encoded image data as a Uint8List.
Implementation
Future<Uint8List> encodePng(Image image) async {
final byteData = await image.toByteData(format: ImageByteFormat.png);
return byteData!.buffer.asUint8List();
}