hash method Null safety

  1. @override
int hash(
  1. Object? e
)
override

Creates a combined hash code for a number of objects.

The hash code is computed for all arguments that are actually supplied, even if they are null, by numerically combining the Object.hashCode of each argument.

Example:

class SomeObject {
  final Object a, b, c;
  SomeObject(this.a, this.b, this.c);
  bool operator=(Object other) =>
      other is SomeObject && a == other.a && b == other.b && c == other.c;
  int get hashCode => Object.hash(a, b, c);
}

The computed value will be consistent when the function is called with the same arguments multiple times during the execution of a single program.

The hash value generated by this function is not guaranteed to be stable over different runs of the same program, or between code run in different isolates of the same program. The exact algorithm used may differ between different platforms, or between different versions of the platform libraries, and it may depend on values that change on each program execution.

The hashAll function gives the same result as this function when called with a collection containing the actual arguments to this function in the same order.

Implementation

@override
int hash(Object? e) => e.hashCode;