hashValue property
This object's hash.
Objects where compareTo is 0 should have the same hashValue. A common mistake is to use an unrelated field when
computing a hashValue
.
Counterexample:
class Foo with Orderable<Foo> {
final String key;
final int value;
Foo(String.key, this.value);
@override
int compareTo(Wrong other) => key.compareTo(other.key);
@override
int get hashValue => Object.hash(key, value);
}
Foo('a', 1) == Foo('a', 2); // true
Foo('a', 1).hashCode == Foo('a', 2).hashCode; // false, violates hash code contract
Implementation
@override
int get hashValue => runtimeType.hashCode ^ dayMicroseconds;