indexToLayoutOffset method
- @Deprecated('The itemExtent is already available within the scope of this function. ' 'This feature was deprecated after v3.20.0-7.0.pre.') double itemExtent,
- int index
The layout offset for the child with the given index.
This function uses the returned value of itemExtentBuilder or the
itemExtent
to avoid recomputing item size repeatedly during layout.
By default, places the children in order, without gaps, starting from layout offset zero.
Implementation
@visibleForTesting
@protected
double indexToLayoutOffset(
@Deprecated(
'The itemExtent is already available within the scope of this function. '
'This feature was deprecated after v3.20.0-7.0.pre.'
)
double itemExtent,
int index,
) {
if (itemExtentBuilder == null) {
itemExtent = this.itemExtent!;
return itemExtent * index;
} else {
double offset = 0.0;
double? itemExtent;
for (int i = 0; i < index; i++) {
final int? childCount = childManager.estimatedChildCount;
if (childCount != null && i > childCount - 1) {
break;
}
itemExtent = itemExtentBuilder!(i, _currentLayoutDimensions);
if (itemExtent == null) {
break;
}
offset += itemExtent;
}
return offset;
}
}