centeredDateLabelOffset function

Offset centeredDateLabelOffset({
  1. required double scrollX,
  2. required double columnLeft,
  3. required double blockWidth,
  4. required double rowHeight,
  5. required Size textSize,
})

The top-left at which a date label of textSize is painted so it sits centered within its day-column: horizontally across the column's blockWidth (its left edge at columnLeft, shifted by the current horizontal scroll scrollX) and vertically within the rowHeight-tall date row. Kept as a pure function so the centering math is unit-testable without a canvas (#28 — labels previously used a hardcoded 60 left offset and a hardcoded 20 top offset and were not centered).

Implementation

Offset centeredDateLabelOffset({
  required double scrollX,
  required double columnLeft,
  required double blockWidth,
  required double rowHeight,
  required Size textSize,
}) =>
    Offset(
      scrollX + columnLeft + (blockWidth - textSize.width) / 2,
      (rowHeight - textSize.height) / 2,
    );