renderBasicItem function

List<Figure> renderBasicItem(
  1. Path path,
  2. Aes aes,
  3. bool hollow,
  4. double strokeWidth, [
  5. Rect? gradientBounds,
])

Renders a basic element item.

This is a util function for implementing Shape.renderGroup and Shape.renderItem. The path should be calculated before it and label is not rendered in it.

See also

Implementation

List<Figure> renderBasicItem(
  Path path,
  Aes aes,
  bool hollow,
  double strokeWidth, [
  Rect? gradientBounds,
]) {
  final rst = <Figure>[];

  final style = Paint();
  if (aes.gradient != null) {
    style.shader = toUIGradient(
      aes.gradient!,
      gradientBounds == null
          ? path.getBounds()
          : path.getBounds().intersect(gradientBounds),
    );
  } else {
    style.color = aes.color!;
  }
  style.style = hollow ? PaintingStyle.stroke : PaintingStyle.fill;
  style.strokeWidth = strokeWidth;

  if (aes.elevation != null && aes.elevation != 0) {
    Color? shadowColor;
    if (aes.gradient != null) {
      shadowColor = getShadowColor(aes.gradient!);
    } else {
      shadowColor = aes.color!;
    }
    rst.add(ShadowFigure(
      path,
      shadowColor,
      aes.elevation!,
    ));
  }

  rst.add(PathFigure(path, style));

  return rst;
}