inRangeOf method
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
int inRangeOf(int min, int max) {
if (min.isNull || max.isNull) throw Exception('min or max cannot be null');
if (min > max) throw ArgumentError('min must be smaller the max');
if (this < min) return min;
if (this > max) return max;
return this;
}