identityHashCode function Null safety

int identityHashCode(
  1. Object? object
)

The identity hash code of object.

Returns the value that the original Object.hashCode would return on this object, even if hashCode has been overridden.

This hash code is compatible with identical, which just means that it's guaranteed to be stable over time.

var identitySet = HashSet(equals: identical, hashCode: identityHashCode);
var dt1 = DateTime.now();
var dt2 = DateTime.fromMicrosecondsSinceEpoch(dt1.microsecondsSinceEpoch);
assert(dt1 == dt2);
identitySet.add(dt1);
print(identitySet.contains(dt1)); // true
print(identitySet.contains(dt2)); // false

Implementation

@pragma("vm:entry-point")
external int identityHashCode(Object? object);