identityHashCode function

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 means that it's guaranteed to give the same result every time it's passed the same argument, throughout a single program execution, for any non-record object.

The identity hash code of a Record is undefined, because a record doesn't have a guranteed persistent identity. A record values identity and identity hash code can change at any time.

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


external int identityHashCode(Object? object);