getGeometryForChildIndex method

  1. @override
SliverGridGeometry getGeometryForChildIndex (int index)
override

The size and position of the child with the given index.

Implementation

@override
SliverGridGeometry getGeometryForChildIndex(int index) {
  final double crossAxisStart = (index % crossAxisCount) * crossAxisStride;
  return SliverGridGeometry(
    scrollOffset: (index ~/ crossAxisCount) * mainAxisStride,
    crossAxisOffset: _getOffsetFromStartInCrossAxis(crossAxisStart),
    mainAxisExtent: childMainAxisExtent,
    crossAxisExtent: childCrossAxisExtent,
  );
}