toPNG method

  1. @override
Future<Uint8List> toPNG()
override

Returns the pixels of this as a PNG data.

Implementation

@override
Future<Uint8List> toPNG() async {
  final image = await toImage();

  final byteData = await image.toByteData(format: ui.ImageByteFormat.png);

  var data = byteData!.buffer
      .asUint8List(byteData.offsetInBytes, byteData.lengthInBytes);

  return data;
}