isEqual method

bool isEqual(
  1. Object other
)

Implementation

@pragma("vm:prefer-inline")
bool isEqual(Object other) {
  _checkArg(other, "other");

  // Same DoubleWithTolerance instance
  if (identical(this, other)) return true;

  final otherValue = switch (other) {
    num() => other,
    DoubleWithTolerance() => other.value,
    _ => throw TypeError(),
  };

  // double value compares equal (double.infinity, ...)
  if (otherValue == value) return true;

  // compare the two values with the given tolerance of this
  // DoubleWithTolerance instance.
  return (otherValue - value).abs() <= epsilon;
}