create static method

Future<ShapePainterCaption> create(
  1. RenderinstructionCaption renderinstruction
)

Creates a new caption shape painter with asynchronous initialization.

Uses a task queue to ensure thread-safe creation and caches the result in the rendering instruction to avoid duplicate creation.

Implementation

static Future<ShapePainterCaption> create(RenderinstructionCaption renderinstruction) async {
  return _taskQueue.add(() async {
    ShapePainterCaption? shapePainter = PainterFactory().getPainterForSerial(renderinstruction.serial) as ShapePainterCaption?;
    if (shapePainter != null) return shapePainter;
    shapePainter = ShapePainterCaption._(renderinstruction);
    PainterFactory().setPainterForSerial(renderinstruction.serial, shapePainter);
    return shapePainter;
  });
}