render method

  1. @override
void render(
  1. Canvas canvas
)
override

This implementation of render basically calls renderComponent for every component, making sure the canvas is reset for each one.

You can override it further to add more custom behaviour. Beware of however you are rendering components if not using this; you must be careful to save and restore the canvas to avoid components messing up with each other.

Implementation

@override
// ignore: must_call_super
void render(Canvas canvas) {
  if (!hasLayout) return;
  canvas.save();

  canvas.translate(size.x / 2, size.y / 2);
  canvas.scale(camera.config.zoom);
  canvas.rotate(camera.config.angle);
  canvas.translate(-camera.position.dx, -camera.position.dy);

  for (final comp in children) {
    renderComponent(canvas, comp);
  }

  canvas.restore();
}