Dart says to avoid equality on mutable classes, that's reasonable. But what about classes with an immutable part like an unique id on which hashcode and equality shall be calculated with and other mutable attributes which shall be ignored. Is that not possible?
Asked
Active
Viewed 286 times
1
-
3"The code is more what you’d call ‘guidelines’ than actual rules.” – Barbossa, Pirates of the Caribbean. In other words, the effective Dart guide lines is not something you are forced to follow but just good advice. If it makes sense for your use case, nothing prevents you from going in a different direction. But I would personally be confused if `==` and `hashCode` did not check all fields in a class. :) – julemand101 Nov 23 '21 at 13:43
-
2totally possible, but some state management solutions may ignore new values emitted as being the same since you don't check the mutable fields for inequality. And this may cause your widgets to not rebuild themselves – pedro pimont Nov 23 '21 at 13:55