painter method

  1. @protected
ElementsPainter Function(ElementsProps?, double) painter(
  1. Shape child
)

Retrieves the appropriate painter for the given child shape.

This method uses the Shape switch expression to get the appropriate painter for the specified child shape.

  • child: The shape of the child element.

Returns a function that creates an ElementsPainter for the specified shape.

Implementation

@protected
// ignore: prefer-typedefs-for-callbacks, Might be a breaking change.
ElementsPainter Function(ElementsProps?, double) painter(Shape child) =>
    switch (child) {
      Star() => StarPainter.new,
      Triangle() => TrianglePainter.new,
      Ellipse() => EllipsePainter.new,
      Rectangle() => RectanglePainter.new,
      Moon() => MoonPainter.new,
      DiagonalLine() => DiagonalLinePainter.new,
    };