draw method Null safety

void draw(
  1. Canvas canvas
)

Draw the drawable components in this artboard.

Implementation

void draw(Canvas canvas) {
  canvas.save();
  canvas.clipRect(Rect.fromLTWH(0, 0, width, height));
  // Get into artboard's world space. This is because the artboard draws
  // components in the artboard's space (in component lingo we call this world
  // space). The artboards themselves are drawn in the editor's world space,
  // which is the world space that is used by stageItems. This is a little
  // confusing and perhaps we should find a better wording for the transform
  // spaces. We used "world space" in components as that's the game engine
  // ratified way of naming the top-most transformation. Perhaps we should
  // rename those to artboardTransform and worldTransform is only reserved for
  // stageItems? The other option is to stick with 'worldTransform' in
  // components and use 'editor or stageTransform' for stageItems.
  canvas.translate(width * originX, height * originY);
  for (final fill in fills) {
    fill.draw(canvas, path);
  }

  for (var drawable = _firstDrawable;
      drawable != null;
      drawable = drawable.prev) {
    if (drawable.isHidden) {
      continue;
    }
    drawable.draw(canvas);
  }
  canvas.restore();
}