inRangeOf method

double inRangeOf(
  1. double min,
  2. double max
)

Return the min if this number is smaller then minimum Return the max if this number is bigger the the maximum Return this number if it's between the range

Implementation

double inRangeOf(double min, double max) {
  if (min > max) throw ArgumentError('min must be smaller the max');

  if (this < min) return min;
  if (this > max) return max;
  return this;
}