clampTo method

num clampTo(
  1. num min,
  2. num max
)

Returns this number constrained to the inclusive range min..max.

Implementation

num clampTo(num min, num max) {
  if (min > max) {
    throw ArgumentError.value(
        min, 'min', 'must be less than or equal to max');
  }
  return this < min ? min : (this > max ? max : this);
}