toPNG method
Returns the pixels of this as a PNG data.
Implementation
@override
Future<Uint8List> toPNG() async {
var blob = await _canvas.toBlob('image/png');
var reader = FileReader();
var completer = Completer<Uint8List>();
reader.onLoadEnd.listen((_) {
var result = reader.result as List<int>;
var bytes = result is Uint8List ? result : Uint8List.fromList(result);
completer.complete(bytes);
});
reader.readAsArrayBuffer(blob);
return completer.future;
}