getMaxChildIndexForScrollOffset method

  1. @protected
int getMaxChildIndexForScrollOffset(
  1. double scrollOffset,
  2. List<double> itemHeights
)

The maximum child index that is visible at the given scroll offset.

This function is given the itemExtent as an argument to avoid recomputing itemExtent repeatedly during layout.

By default, returns a value consistent with the children being placed in order, without gaps, starting from layout offset zero.

Implementation

@protected
int getMaxChildIndexForScrollOffset(
    double scrollOffset, List<double> itemHeights) {
  final _result = binarySearchReturnLowest(itemHeights, scrollOffset,
          matchReturnsMin: true)
      .clamp(0, itemHeights.length - 1);
  return _result;
}