fluttercommunity / flutter_contacts

Contacts Service - A Flutter plugin to retrieve and manage contacts on Android and iOS devices. Maintainer: @lukasgit
https://pub.dev/packages/contacts_service
MIT License
153 stars 69 forks source link

Request: Lookup phone number #6

Closed ParitoshBh closed 5 years ago

ParitoshBh commented 6 years ago

They contact query (by name, I am guessing) works very well. However, is there a way to lookup contact(s) based on a phone number?

I understand this isn't something on your to-do list but it'd be great to know if there's a way to do so in library's current state?

clovisnicolas commented 6 years ago

As a workaround, you can fetch all contacts and then filter them based on the phone number values : Something like this could work :

var allContacts = await ContactsService.getContacts();
var filtered = allContacts.where((c) => c.phones.any((phone) => phone.value.contains("123456789"))).toList();
ParitoshBh commented 6 years ago

That was my first thought but from a performance stand point would this be slower than using something like ContactsContract.PhoneLookup?

clovisnicolas commented 6 years ago

Yes I guess that would be more performant, especially if you have 100's of contacts. I doubt i will be adding this to the library any time soon though. PRs are welcome :)

ParitoshBh commented 6 years ago

I will try to push a PR as and when I get time :)

lukasgit commented 5 years ago

Closing this issue due to lack of interest from the community to lookup a phone number. If someone would like to contribute I will re-open this issue. Thanks!