isItemVisible method

bool isItemVisible(
  1. int index,
  2. double itemHeight
)

Checks if the item at the given index is currently visible within the scroll view.

index is the target index of the item. itemHeight is the height of a single item.

Implementation

bool isItemVisible(int index, double itemHeight) {
  double itemOffset = index * itemHeight;
  double itemEndOffset = itemOffset + itemHeight;
  double currentPosition = position.pixels;
  return currentPosition >= itemOffset && currentPosition <= itemEndOffset;
}