isBetween method

bool isBetween(
  1. num min,
  2. num max, {
  3. bool includeMin = true,
  4. bool includeMax = true,
})

Returns true if this number is between min and max.

Implementation

bool isBetween(
  num min,
  num max, {
  bool includeMin = true,
  bool includeMax = true,
}) {
  if (min > max) {
    throw ArgumentError.value(
        min, 'min', 'must be less than or equal to max');
  }

  final lower = includeMin ? this >= min : this > min;
  final upper = includeMax ? this <= max : this < max;
  return lower && upper;
}