gridView method

CarpetStyle gridView({
  1. int width = 1,
  2. int height = 1,
  3. int tileSize = 250,
  4. int quiltHeightMultiplier = 1,
})

Configures a grid-view style for multi-cell uniform layouts.

Computes columns based on tile size and cell counts, disabling scalar tiles for strict grids. Used in Carpet for galleries or tables.

Implementation

CarpetStyle gridView(
        {int width = 1,
        int height = 1,
        int tileSize = 250,
        int quiltHeightMultiplier = 1}) =>
    copyWith(
        carpetWidthCalc: (context) {
          int w = MediaQuery.of(context).size.width ~/ tileSize;

          while (w % width != 0) {
            w++;
          }

          return w;
        },
        maxTileWidth: width,
        minTileWidth: width,
        minTileHeight: height,
        maxTileHeight: height,
        maxQuiltHeight: quiltHeightMultiplier * height,
        allowScalarTiles: false);