getMaxChildIndexForScrollOffset method

  1. @protected
int getMaxChildIndexForScrollOffset (double scrollOffset, double itemExtent)
@protected

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, double itemExtent) {
  return itemExtent > 0.0 ? math.max(0, (scrollOffset / itemExtent).ceil() - 1) : 0;
}