ensureVisible method

void ensureVisible(
  1. int index,
  2. int viewportHeight
)

Adjusts offset so that index is visible within a viewport of viewportHeight rows.

Implementation

void ensureVisible(int index, int viewportHeight) {
  if (viewportHeight <= 0) return;

  final int bottomVisible = _offset + viewportHeight - 1;

  if (index < _offset) {
    offset = index;
  } else if (index > bottomVisible) {
    offset = index - viewportHeight + 1;
  }
}