ContactsService.addContact to return id/displayName
See original GitHub issueNot sure if possible with Android/iOS, but I would appreciate if ContactsService.addContact(contact)
would:
- set
contact.id
andcontact.displayName
as generated upon insertion - or return a
Future<Contact>
with the newly inserted contact includingid
anddisplayName
My use case is adding a new contact and then immediately switching to the contact update page (or rather going add -> detail -> update). To call ContactsService.updateContact(contact)
, contact.id
must be set but I do not know it a priori after adding.
My current workaround is to reload the contact with ContactsService.getContacts(query = [contact.givenName, contact.middleName, contact.familyName].where((s) => s != null).join (" "))
but this fails e.g. if no familyName
is set. Loading all contacts and then searching manually would also be possible but time consuming.
In summary, getting the id
/displayName
from addContact
would be a much cleaner solution, and I would much prefer it to my current, somewhat hacky, workaround.
Issue Analytics
- State:
- Created 4 years ago
- Reactions:1
- Comments:8 (2 by maintainers)
Top GitHub Comments
I have a PR that does something like that: https://github.com/fluttercommunity/flutter_contacts/compare/450a0788ff5faa34fcd584075f315c87d185ffeb..52b93360a8fafdd1c5c22c49b067320fcb8b1d1b
But only works on android.
@z0mbie42 If you add a contact, you do so with an account (e.g. DavX, Google, Exchange etc.), resulting in a “raw” contact. Now suppose you have a raw contact with displayName “Jane Doe” (Google), then add a raw contact “Jane Doe” (Exchange). When reading, you do not lead the two raw contacts, but rather an aggregated/unified contact. So the table looks like this:
For more detailed examples: http://android-contact-id-vs-raw-contact-id.blogspot.com/