forceInRange method

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

Returns the min if the number is less than min, max if greater than max, or the number itself otherwise.

Implementation

num forceInRange(num min, final num max) => this < min ? min : (this > max ? max : this);