-
-
Notifications
You must be signed in to change notification settings - Fork 14
DataField property to ignore field from equatable props #20
Comments
suggest a name for the said property, I am struggling to find a good name :P |
|
Instead of blindly adding this feature I'd like to see a real-world example where this is useful.
And I've never seen a good example where a partially equals method implementation actually made sense. It might only be used for a special use case and might be better implemented using a custom comparison method, not the void main() {
final itemA = Item("A");
final itemB = Item("B")..added = false;
final itemB2 = Item("B")..added = true;
print(itemA == itemB); // false
print(itemB == itemB2); // false
print(itemA.customEquals(itemB)); // false
print(itemB.customEquals(itemB2)); // true
}
class Item {
Item(this.name);
final String name;
// mutable property
bool added;
}
extension ItemEquality on Item {
/// Only checks for the name
bool customEquals(dynamic other) => (other is Item) && name == other.name;
} My recommendation: Add a property to skip generating the equals method at all. It could be useful for mutable super_enums. Users of such classes then could implement an |
@passsy yes, makes sense to me. |
Currently, we don't have any option or property to mark a
DataField
to be ignored fromequatable props
. We should add a property for the same.The text was updated successfully, but these errors were encountered: