operator == method

  1. @override
bool operator ==(
  1. Object other
)
override

Equality operator that compares both coordinates

Essential for correct behavior in collections like Set and Map. Follows Dart's equality contract:

  1. Reflexive: a == a
  2. Symmetric: a == b ⇒ b == a
  3. Transitive: a == b && b == c ⇒ a == c

Implementation

@override
bool operator ==(Object other) =>
    identical(this, other) || // Reference equality check
    other is GridCell && // Type check
        runtimeType == other.runtimeType && // Subtype check
        x == other.x && // Coordinate comparison
        y == other.y;