clampInt method Null safety

int clampInt(
  1. int min,
  2. int max,
  3. int input
)

Clamps an integer between two integers.

Returns input when min <= input <= max, and either min or max otherwise.

Implementation

static int clampInt(int min, int max, int input) {
  if (input < min) {
    return min;
  } else if (input > max) {
    return max;
  }

  return input;
}