compute method

CarpetStyle compute(
  1. BuildContext context
)

Computes and validates style parameters based on the current context.

Applies device-specific adjustments to ensure valid dimensions, clamping values for feasibility. Returns a new CarpetStyle ready for use in QuiltFaucet and Carpet rendering, integrating with MediaQuery for responsiveness.

Implementation

CarpetStyle compute(BuildContext context) {
  int carpetWidth = max(1, carpetWidthCalc(context));
  int maxTileWidth = max(1, min(this.maxTileWidth, carpetWidth));
  int maxTileHeight = max(1, min(this.maxTileHeight, maxQuiltHeight));
  int minTileWidth = max(1, min(this.minTileWidth, maxTileWidth));
  int minTileHeight = max(1, min(this.minTileHeight, maxTileHeight));

  return copyWith(
      carpetWidth: carpetWidth,
      maxTileWidth: maxTileWidth,
      maxTileHeight: maxTileHeight,
      minTileWidth: minTileWidth,
      minTileHeight: minTileHeight,
      maxSizeOptions: max(1, min(maxSizeOptions, 64)));
}