Equality mixin
A mixin for implementing equality based on a list of properties.
This mixin provides an implementation of the equality operator ==
and the hash code getter hashCode
based on a list of properties (props
). It ensures that objects are considered equal if they have the same
runtime type and their corresponding properties in the props
list are deeply equal.
Example usage:
class MyClass with Equality {
final int id;
final String name;
MyClass(this.id, this.name);
@override
List get props => [id, name];
}
In this example, two MyClass
objects are considered equal if they have the same id
and name
.
The props
list specifies the properties that are used for determining equality.
- Mixin applications
Properties
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
override