getOrCreateShapePainter<T extends Renderinstruction> method

Future<ShapePainter<T>> getOrCreateShapePainter<T extends Renderinstruction>(
  1. RenderInfo<T> renderInfo
)

Creates a shape painter for the given render information.

Returns cached painter if available, otherwise creates a new painter based on the rendering instruction type. Some painters (like captions) are context-dependent and not cached for reuse.

renderInfo Render information containing the instruction and context Returns appropriate shape painter for the instruction type

Implementation

Future<ShapePainter<T>> getOrCreateShapePainter<T extends Renderinstruction>(RenderInfo<T> renderInfo) async {
  if (renderInfo.shapePainter != null) return renderInfo.shapePainter!;

  ShapePainter? shapePainter = _shapePainters[renderInfo.renderInstruction.serial];
  if (shapePainter != null) {
    renderInfo.shapePainter = shapePainter as ShapePainter<T>;
    return shapePainter;
  }

  return await createShapePainter(renderInfo);
}