computeMaxScrollOffset method

  1. @override
double computeMaxScrollOffset(
  1. int childCount
)
override

The scroll extent needed to fully display all the tiles if there are childCount children in total.

The child count will never be null.

Implementation

@override
double computeMaxScrollOffset(int childCount) {
  if (childCount == 0) {
    // There are no children in the grid. The max scroll offset should be
    // zero.
    return 0.0;
  }
  final int mainAxisCount = ((childCount - 1) ~/ crossAxisCount) + 1;
  final double mainAxisSpacing = mainAxisStride - childMainAxisExtent;
  return mainAxisStride * mainAxisCount - mainAxisSpacing;
}