viewportIndex method

int viewportIndex(
  1. int index, [
  2. List<int>? visibleIndexes
])

Implementation

int viewportIndex(int index, [List<int>? visibleIndexes]) {
  if (visibleIndexes != null && visibleIndexes.isNotEmpty) {
    if (canFindLinearVisibleIndexes) {
      final int start = visibleIndexes[0];
      final int end = visibleIndexes[1] + 1;
      int viewportIndex = 0;
      for (int i = start; i < end; i++) {
        if (i == index) {
          return viewportIndex;
        }
        viewportIndex++;
      }
    } else {
      return visibleIndexes.indexOf(index);
    }
  }
  return -1;
}