indexToLayoutOffset method

  1. @protected
double indexToLayoutOffset(
  1. List<double> itemHeights,
  2. int index
)

The layout offset for the child with the given index.

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

By default, places the children in order, without gaps, starting from layout offset zero.

Implementation

@protected
double indexToLayoutOffset(List<double> itemHeights, int index) {
  if (index < 0) {
    return 0;
  }
  if (index >= itemHeights.length) {
    return itemHeights.last;
  }
  return itemHeights[index];
}