isInInterval method

bool isInInterval(
  1. num a,
  2. num b, {
  3. bool excludeA = false,
  4. bool excludeB = false,
})

Checks if this number is within the interval a, b.

Use excludeA or excludeB to make the interval open at either end.

Implementation

bool isInInterval(
  num a,
  num b, {
  bool excludeA = false,
  bool excludeB = false,
}) {
  if (excludeA && this == a) return false;
  if (excludeB && this == b) return false;
  return this >= a && this <= b;
}