Comments (5)
@lukasgit if you could help me with this that would be great cuz the current solution (converting to json, then comparing that) is very slow in comparison to comparing the objects directly
from flutter_contacts.
After further inspection things seem to fail here specifically
DeepCollectionEquality.unordered().equals
Im going to try to convert them to sets and then simply doing a .contains
from flutter_contacts.
Hi @b-cancel we are swamped right now and with limited resources available at the moment. Please feel free to contribute updates and improvements via PR.
Also, major code changes were recently pushed. You will want to grab the latest code. Thanks!
from flutter_contacts.
@lukasgit I am swapped too... but I'll put this here for when I have time...
So this is how I solved it
Not sure if its the best way (which is why I don't do a PR) but it works
&& itemsEqual(
castToList(c1.phones),
castToList(c2.phones),
)
&& itemsEqual(
castToList(c1.emails),
castToList(c2.emails),
)
&& postalAddressesEqual(
castToList(c1.postalAddresses),
castToList(c2.postalAddresses),
)
Using The Functions Below
//-----For Both
List castToList(var list){
if(list.runtimeType == new List().runtimeType) return list;
else return list.toList();
}
//-----For Items
bool itemsEqual(List<Item> l1, List<Item> l2){
if(l1.length != l2.length) return false;
else{
Set<Item> s1 = l1.toSet();
for(int i = 0; i < l2.length; i++){
if(s1.contains(l2[i]) == false) return false;
}
return true;
}
}
//-----For Postal Addressses
bool postalAddressesEqual(List<PostalAddress> l1, List<PostalAddress> l2){
if(l1.length != l2.length) return false;
else{
Set<PostalAddress> s1 = l1.toSet();
for(int i = 0; i < l2.length; i++){
if(s1.contains(l2[i]) == false) return false;
}
return true;
}
}
from flutter_contacts.
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
from flutter_contacts.
Related Issues (20)
- Update contact and delete contact not working HOT 9
- ...
- LOOKING FOR CONTRIBUTORS HOT 7
- java.lang.NoClassDefFoundError HOT 1
- Contact saved with wrong label HOT 3
- Exception when you cancel editing contact on android HOT 1
- I want birthday without year HOT 1
- OpenContactForm should take initial Contact HOT 3
- ios contacts HOT 2
- ContactsServicePlugin.java line 521 flutter.plugins.contactsservice.contactsservice.ContactsServicePlugin.getCursor HOT 1
- A problem occurred configuring project ':contacts_service'. HOT 1
- openContactForm initial value
- need to update all package
- Update package
- Phone number label not being persisted when adding a Contact
- Here are 201 public repositories matching this topic... HOT 1
- Here are 201 public repositories matching this topic... HOT 6
- error Android
- Upgrade package?
- doesn't access contacts in release mode
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flutter_contacts.