clampTo method
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);
}