SunnyApp / flutter_contact

A flutter plugin for retrieving, creating, saving, and watching contacts on native devices
BSD 3-Clause "New" or "Revised" License
81 stars 62 forks source link

contact is added but plugin is throwing exception #27

Open kw2019ltd opened 4 years ago

kw2019ltd commented 4 years ago

trying to add Contact using Contacts.addContact(contact); using flutter_contact: ^0.6.4

  var contact =
      Contact(givenName: 'HHH', displayName: 'dd', identifier: '234234');
      Contacts.addContact(contact);

getting below error but contact is being added see below screen pls fix it

{identifier: 234234, displayName: dd, givenName: HHH, middleName: null, familyName: null, lastModified: null, unifiedContactId: null, singleContactId: null, otherKeys: {}, prefix: null, suffix: null, company: null, jobTitle: null, emails: [], phones: [], dates: [], socialProfiles: [], urls: [], postalAddresses: [], avatar: null, note: null}

I/flutter ( 5100): ══╡ EXCEPTION CAUGHT BY FLUTTER FRAMEWORK ╞═════════════════════════════════════════════════════════ I/flutter ( 5100): The following PlatformException was thrown: I/flutter ( 5100): PlatformException(notFound, in method getContact: Expected a single result for contact I/flutter ( 5100): ContactKeys(mode=UNIFIED, unifiedContactId=1226, singleContactId=null, lookupKey=null), but instead I/flutter ( 5100): found 0, co.sunnyapp.flutter_contact.MethodCallException: notFound: in method getContact: Expected a I/flutter ( 5100): single result for contact ContactKeys(mode=UNIFIED, unifiedContactId=1226, singleContactId=null, I/flutter ( 5100): lookupKey=null), but instead found 0)

image

ericmartineau commented 3 years ago

Is this ios? Android? And does it happen every time? Or just sometimes?

Chinmay-KB commented 3 years ago

I am getting the same error, I am providing display name, family name and phones

ericmartineau commented 3 years ago

I haven't tested the behavior, but I don't think you should be providing an identifier - I believe that should be set by the underlying framework. What happens if you remove the identifier field?

rmortes commented 3 years ago

Related to https://github.com/SunnyApp/flutter_contact/issues/11

GeylanKalafMohe commented 1 month ago

Issue still happens. Please fix it

await Contacts.addContact(Contact(givenName: 'HHH', displayName: 'dd'));

PlatformException (PlatformException(notFound, in method getContact: Expected a single result for contact ContactKeys(mode=UNIFIED, unifiedContactId=220335, singleContactId=null, lookupKey=null), but instead found 0, co.sunnyapp.flutter_contact.MethodCallException: notFound: in method getContact: Expected a single result for contact ContactKeys(mode=UNIFIED, unifiedContactId=220335, singleContactId=null, lookupKey=null), but instead found 0, null))

GeylanKalafMohe commented 1 month ago

Temp fix is to just put it in try catch but not handle the error