Giter VIP home page Giter VIP logo

Comments (5)

b-cancel avatar b-cancel commented on July 26, 2024

@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.

b-cancel avatar b-cancel commented on July 26, 2024

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.

lukasgit avatar lukasgit commented on July 26, 2024

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.

b-cancel avatar b-cancel commented on July 26, 2024

@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.

stale avatar stale commented on July 26, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.