clampWidthInRange function

double clampWidthInRange(
  1. double minInpercent,
  2. double maxInpx,
  3. BuildContext context
)

The function clamps a dimension value between a minimum percentage and a maximum pixel value based on the current width of the context.

Args: minInpercent (double): The minimum dimension value in percentage of the current width. maxInpx (double): The maximum width in pixels. context (BuildContext): The BuildContext object represents the current build context of the widget tree. It provides information about the current state of the application, such as the size and position of widgets.

Container(
    color: Colors.red,
    width: clampDimensionWithCurrentWidth(50, 500, context),
  //Gives a width of 50% of current-width and
  //stops after it has reached a width of 500 px
);

Implementation

double clampWidthInRange(
        double minInpercent, double maxInpx, BuildContext context) =>
    (minInpercent.cw(context) >= maxInpx) ? maxInpx : minInpercent.cw(context);