renderToPictureRecorder method
Implementation
PictureRecorder renderToPictureRecorder(double width, double height) {
var bounds = skeleton.getBounds();
var scale = 1 / (bounds.width > bounds.height ? bounds.width / width : bounds.height / height);
var recorder = PictureRecorder();
var canvas = Canvas(recorder);
var bgColor = Random().nextInt(0xffffffff) | 0xff0000000;
var paint = Paint()
..color = material.Color(bgColor)
..style = PaintingStyle.fill;
canvas.drawRect(Rect.fromLTWH(0, 0, width, height), paint);
canvas.translate(width / 2, height / 2);
canvas.scale(scale, scale);
canvas.translate(-(bounds.x + bounds.width / 2), -(bounds.y + bounds.height / 2));
canvas.drawRect(const Rect.fromLTRB(-5, -5, 5, -5), paint..color = material.Colors.red);
renderToCanvas(canvas);
return recorder;
}