getEntry method

ParagraphEntry getEntry(
  1. String text,
  2. UiTextPaint textPaint,
  3. UiPaint paint,
  4. double maxTextWidth,
)

Retrieves or creates a cached ParagraphEntry for the given text and style.

A unique key is generated from the text content and styling parameters. If an entry for this key exists in the cache, it is returned. Otherwise, a new ParagraphEntry is created, cached, and returned.

Implementation

ParagraphEntry getEntry(String text, UiTextPaint textPaint, UiPaint paint, double maxTextWidth) {
  String key =
      "$text-${textPaint.getFontFamily()}-${textPaint.getTextSize()}-${textPaint.getFontStyle().name}-${paint.getStrokeWidth()}-${paint.getColorAsNumber()}-$maxTextWidth";
  ParagraphEntry result = _cache.getOrProduceSync(key, (_) {
    return ParagraphEntry(text, paint, textPaint, maxTextWidth);
  });
  return result;
}