convertSizedItemByAutoFill method

void convertSizedItemByAutoFill(
  1. BoxConstraints constraints
)

Implementation

void convertSizedItemByAutoFill(BoxConstraints constraints) {
  if (autoFillItems.isEmpty) {
    return;
  }

  final itemWidth = (constraints.maxWidth -
          (columnCount - 1) * itemPadding.width -
          layoutPadding.horizontal) /
      columnCount;
  final rowCount = (autoFillItems.length / columnCount).ceil();
  final itemHeight = (constraints.maxHeight -
          (rowCount - 1) * itemPadding.height -
          layoutPadding.vertical) /
      rowCount;

  sizedItems.clear();
  for (final item in autoFillItems) {
    sizedItems.add(
      GridLayoutSizedItem(
        id: item.id,
        width: itemWidth,
        height: itemHeight,
        child: item.child,
      ),
    );
  }
}