mainAxisExtent function

int mainAxisExtent(
  1. Layout layout, {
  2. bool horizontal = false,
})

Returns the layout's extent along the main axis: the bottom-most edge for a vertically scrolling grid, the right-most edge when horizontal.

Implementation

int mainAxisExtent(Layout layout, {bool horizontal = false}) {
  var max = 0;
  for (final item in layout) {
    final end = horizontal ? item.x + item.w : item.y + item.h;
    if (end > max) max = end;
  }
  return max;
}