cellOrigin method

({double leftMm, double topMm}) cellOrigin(
  1. int index
)

Top-left corner of the cell at index (0-based, row by row).

Implementation

({double leftMm, double topMm}) cellOrigin(int index) {
  final column = index % columns;
  final row = (index ~/ columns) % rows;
  return (
    leftMm: marginLeftMm + column * (cellWidthMm + gapXMm),
    topMm: marginTopMm + row * (cellHeightMm + gapYMm),
  );
}