DataField class
Specify the comparator and hash function to use for a given property.
This annotation controls the comparator and hash function to use for a given property when generating the equals and hashCode functions for a given class that is annotated with DataClass or CellExtension.
The function equals is used, instead of ==
, to compare whether two
properties are equal. Similarly the function hash is used to compute the
hash code of the property instead of the Object.hashCode property.
Example:
@DataClass()
class Point {
// Use `listEquals` from `flutter:foundation.dart` as the comparator and
// `Object.hashAll` as the hash function for this property.
@DataField(
equals: listEquals,
hash: Object.hashAll
)
final List<int> coordinates;
...
@override
bool operator ==(Object other) => _$PointEquals(this, other);
@override
int get hashCode => _$PointHashCode(this);
}
Constructors
- DataField.new({Function? equals, Function? hash})
-
const
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.
inherited