export method
Implementation
Future<Uint8List?> export(Size canvasSize) async {
var recorder = PictureRecorder();
var origin = const Offset(0.0, 0.0);
var paintBounds = Rect.fromPoints(
canvasSize.topLeft(origin),
canvasSize.bottomRight(origin),
);
var canvas = Canvas(recorder, paintBounds);
paint(canvas, canvasSize);
var picture = recorder.endRecording();
var image = await Future.value(picture.toImage(
canvasSize.width.round(),
canvasSize.height.round(),
));
ByteData? bytes = await image.toByteData(format: ImageByteFormat.png);
return bytes?.buffer.asUint8List();
}