isBetween method Null safety

bool isBetween(
  1. num first,
  2. num second
)

Returns a bool if this value is between (including) the two numeric values first and second.

Example:

100.isBetween(50, 150) // true;
100.isBetween(50.0, 150.0) // true;
100.isBetween(100, 100) // true;

Implementation

bool isBetween(num first, num second) {
  if (first <= second) {
    return this >= first && this <= second;
  } else {
    return this >= second && this <= first;
  }
}