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
Lists even if elements are Equatable don't cause changes #85
Comments
Hi @JohnGalt1717 👋 Can you please provide a link to a reproduction sample? Thanks! 🙏 |
@felangel Don't know what there is to reproduce. Lists don't cause equatable to change status. It's that simple. It ignores add/deletes of items from the list. |
@JohnGalt1717 having a concrete reproduction sample would help because we can be sure we are looking at the exact same scenario. For example, are you mutating the list (sounds like it) or are you creating a new instance of the list with the added item? I'm happy to take the time to investigate this but I would really appreciate if you could take the time to create a simple reproduction sample, thanks! |
Standard process of immutable classses. Create one with a list. |
There are currently tests for this equatable/test/equatable_test.dart Line 655 in baf9a66
Is there a case that is missing? I'm not sure why you are so resistant to sharing a small chunk of code which reproduces the issue you're facing -- it's making it harder to reach a solution. |
I'm trying to. create a class, put a property in the class that is a list, set props = [listprop] Compare the original and the copy of the class. Equatable says that the 2 are the same. They are not. The tests you just linked to compare 2 lists, not to objects with lists in them. |
Rather than describing in words can you share the dart code? There are tests for classes with lists in them as well: equatable/test/equatable_test.dart Line 497 in baf9a66
|
The following:
Results in equatable = true on line 29 and 34. They're clearly not because objB doesn't have the same number of elements that objC has in values as an example. It should have returned false in both cases because values has a different length. |
@JohnGalt1717 this is because you are mutating values. If instead you created a new instance of objB with a final objC = objB.copyWith(values: List.of(objB.values)..add(ListObject(true)));
print(objB == objC); // false This is documented in the
Hope that helps 👍 |
Describe the bug
If a list is one of the properties on an object, then add/remove and per item comparisons fail which causes things like FlutterBloc etc. that rely on equitable to determine if something has changed, to also fail.
To Reproduce
Expected behavior
Equatable should by default inspect all elements for equatableness of a list and flag the property dirty based on an mismatch in size or specific elements changing. Alternatively this should be a setting that you can configure, or there should be a specific type of list (EquatableList<>) that will explicitly cause the same.
Version
Dart SDK version: 2.10.0-7.3.beta (beta) (Wed Aug 26 09:46:50 2020 +0200) on "windows_x64"
The text was updated successfully, but these errors were encountered: