drawHeaders method

void drawHeaders(
  1. Canvas canvas,
  2. Size size
)

Implementation

void drawHeaders(Canvas canvas, Size size) {
  late List<double> headerTops;
  if (firstCycle) headerTops = [];

  for (int i = 0; i < headerSpans.length; i++) {
    TextSpan span = headerSpans[i];
    textPainter.text = span;
    textPainter.layout();
    double scrollOffset = scrollController.offset;
    double headerTop = getHeaderTop(i, i, span);
    headerTops.add(headerTop + headerSize);
    double posTop = headerTop < scrollOffset ? scrollOffset : headerTop;
    bool isInvisible =
    drawItems(canvas, size, headers[i], headerTop + headerSize);
    if (isInvisible) continue;
    painter.color = headerColor;
    canvas.drawRect(
        Rect.fromLTWH(0, posTop, boxSize * crossAxisCount, headerSize),
        painter);
    painter.color = backgroundColor;
    textPainter.paint(canvas, Offset(2.5, posTop + 5));
  }

  if (firstCycle) onCanvasChanged(headerTops);
}