compareWith method

bool compareWith(
  1. Object other
)
inherited

Compares this object with another for equality.

This is the implementation behind the == operator. It checks:

  1. Identity (same reference)
  2. Type equality
  3. props equality (deep comparison)

When to use directly: Call this from a custom == override if you need pre/post processing:

@override
operator ==(Object other) {
  if (other is! MyRoute) return false;
  // Custom pre-check
  return compareWith(other);
}

Implementation

@pragma('vm:prefer-inline')
bool compareWith(Object other) {
  if (identical(this, other)) return true;
  return other is Equatable &&
      other.runtimeType == runtimeType &&
      iterableEquals(props, other.props);
}