ValueKey<T> class Null safety

A key that uses a value of a particular type to identify itself.

A ValueKey<T> is equal to another ValueKey<T> if, and only if, their values are operator==.

This class can be subclassed to create value keys that will not be equal to other value keys that happen to use the same value. If the subclass is private, this results in a value key type that cannot collide with keys from other sources, which could be useful, for example, if the keys are being used as fallbacks in the same scope as keys supplied from another widget.

See also:

  • Widget.key, which discusses how widgets use keys.
Inheritance
Implementers

Constructors

ValueKey(T value)
Creates a key that delegates its operator== to the given value.
const

Properties

hashCode int
The hash code for this object.
read-onlyoverride
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
value → T
The value to which this key delegates its operator==
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toString() String
A string representation of this object.
override

Operators

operator ==(Object other) bool
The equality operator.
override