ensureVisible method
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;
}
}