clampTo method
Clamps the number between min and max.
Example:
15.clampTo(0, 10); // 10
5.clampTo(0, 10); // 5
Implementation
int clampTo(int min, int max) {
assert(min <= max, 'min must be less than or equal to max');
return this < min ? min : (this > max ? max : this);
}