-
-
Notifications
You must be signed in to change notification settings - Fork 521
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
fix: add deep compare to update dropdown items #1272
Conversation
Codecov Report
@@ Coverage Diff @@
## main #1272 +/- ##
==========================================
- Coverage 84.98% 84.94% -0.05%
==========================================
Files 20 21 +1
Lines 706 724 +18
==========================================
+ Hits 600 615 +15
- Misses 106 109 +3
... and 1 file with indirect coverage changes 📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @deandreamatias, please check the suggested changes.
Other than the highlighted error, I think the code is well done. HOWEVER, there is still a loophole to this condition Example: main(){
print([
Continent(id: 1, name: 'Africa'),
Continent(id: 2, name: 'Asia'),
Continent(id: 3, name: 'Europe'),
].contains(Continent(id: 1, name: 'Africa'))); // PRINTS `true` because the Continent class is 'equatable'
// WHILE
print([
Country(id: 2, name: 'India', continentId: 2),
Country(id: 3, name: 'Spain', continentId: 3),
Country(id: 3, name: 'France', continentId: 3),
].contains(Country(id: 2, name: 'India', continentId: 2))); // PRINTS `false` because the Country class is NOT 'equatable'
}
class Continent {
final int id;
final String name;
Continent({required this.id, required this.name});
@override
operator ==(Object other){
return other is Continent && other.id == id;
}
@override
int get hashCode => id.hashCode;
}
class Country {
final int id;
final String name;
final int continentId;
Country({required this.id, required this.name, required this.continentId});
} It is therefore up to the user to make sure that that's the case. For example, in the example of the original issue that we're solving, if the Since there's nothing more we could do about that, I applaud @deandreamatias's efforts to prevent the user of the library from shooting themselves in the foot. Good work! You can resolve the reviews then go ahead and merge. Thanks. |
Connection with issue(s)
Close #1252
Connected to #687
Connected to #1239
Solution description
Add a deep compare to reset dropdown only when items are really different.
I considered remove the verification and transfer it responsibility to reset dropdown to developer users (like @danvick says on this comment), but I thinks that this behavior is a important to have embedded on package because is a feature that able implement related fields with minor effort.
Screenshots or Videos
Test behavior of original issue (#1252)
Screencast.from.15-07-23.14.23.59.webm
Test behavior of related issue (#687)
Screencast.from.15-07-23.14.25.01.webm
To Do