columnLength method

int columnLength()

Implementation

int columnLength() {
  int gridItemCount = itemCount;

  if (wantLoadMore) {
    // Fill remaining slots in the row to push loader to a new row
    int remainingSlots = crossAxisCount - (itemCount % crossAxisCount);

    if (remainingSlots == crossAxisCount) {
      remainingSlots = 0; // No slots left if full row
    }

    gridItemCount += remainingSlots;

    // Now add one more for the loader row
    gridItemCount += crossAxisCount;
  }

  return (gridItemCount / crossAxisCount).ceil();
}