You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have a question about how to compare lists of instances extending Equatable.
Dart == for list does not compare their elements, but hashcode as you know.
So when you compare two instances even extending Equatable, the result would be always false.
The comparison does not depend on their values. This is an expected behavior I guess.
But I would like to know if there's any practice to do it. I'd appreciate it if you have any suggestions.
To Reproduce
classEextendsEquatable {
constE(this.value);
finalint value;
@overrideList<Object> get props => [value];
}
final originalList = [E(1), E(1), E(1)];
final a = [...originalList];
final b = [...originalList];
a == b; // return false, expected to be true
Expected behavior
Expected the comparison to return true, comparing depending on their actual values, not hashcode.
Version
Dart version 2.8.4
Additional context
N/A
The text was updated successfully, but these errors were encountered:
Describe the question
I have a question about how to compare lists of instances extending Equatable.
Dart
==
for list does not compare their elements, but hashcode as you know.So when you compare two instances even extending Equatable, the result would be always false.
The comparison does not depend on their values. This is an expected behavior I guess.
But I would like to know if there's any practice to do it. I'd appreciate it if you have any suggestions.
To Reproduce
Expected behavior
Expected the comparison to return true, comparing depending on their actual values, not hashcode.
Version
Dart version 2.8.4
Additional context
N/A
The text was updated successfully, but these errors were encountered: