clampHeightInRange function

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

The function clamps a dimension value between a minimum percentage of the current height and a maximum pixel value.

Args: minInpercent (double): The minimum dimension value in percentage of the current height. maxInpx (double): The maximum value in pixels that the dimension can have. context (BuildContext): The BuildContext object represents the current build context of the widget tree. It provides information about the current state of the application and allows access to various properties and methods related to the current build context.

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

Implementation

double clampHeightInRange(
        double minInpercent, double maxInpx, BuildContext context) =>
    (minInpercent.ch(context) >= maxInpx) ? maxInpx : minInpercent.ch(context);