calculateContentHeight static method

double calculateContentHeight({
  1. required int itemCount,
  2. double rowHeight = 40.0,
  3. double rowSpacing = 0.0,
  4. double topPadding = 0.0,
  5. double bottomPadding = 0.0,
})

Calculate the total content height from a flat item count.

Since all rows have the same fixed height, this is O(1).

Implementation

static double calculateContentHeight({
  required int itemCount,
  double rowHeight = 40.0,
  double rowSpacing = 0.0,
  double topPadding = 0.0,
  double bottomPadding = 0.0,
}) {
  if (itemCount == 0) return topPadding + bottomPadding;

  final totalRowHeight = itemCount * rowHeight;
  final totalSpacing = (itemCount - 1) * rowSpacing;

  return totalRowHeight + totalSpacing + topPadding + bottomPadding;
}