QuisApp / flutter_contacts

MIT License
83 stars 138 forks source link

Possible Bug: When Importing Contacts With Phone Number - No Phone Numbers Appear (On Emulated Device) #166

Closed TomerPacific closed 2 months ago

TomerPacific commented 2 months ago

I am using flutter_contacts version 1.1.7+1 to handle importing contacts in my application.

When testing things out, I created a contact on an emulated device and have added two phone numbers to it.

contact1

Then, when importing the contact, I see that the phones attribute under the Contact object is empty.

contact2

What could be the cause of this?

You can also see that the isStarred attribute is marked as true, even though that is not true for the contact.

The emulated device I am using is a Pixel 4 with API 29

joachim-quis commented 2 months ago

Hi @TomerPacific - can you post the code you used?

TomerPacific commented 2 months ago

@joachim-quis - I am getting contacts using this:

await FlutterContacts.getContacts();

and then I am iterating over the List that it returns like this:

for (Contact contact in users) {
      DateTime? chosenBirthDate = await showDatePicker(context: context,
          initialDate: DateTime(1970, 1, 1),
          firstDate: DateTime(1970, 1, 1),
          lastDate: DateTime.now(),
          initialEntryMode: DatePickerEntryMode.input,
          helpText: "Choose birth date for ${contact.displayName}",
          fieldLabelText: "${contact.displayName}'s birth date"
      );

      if (chosenBirthDate != null) {
        UserBirthday userBirthday = new UserBirthday(contact.displayName,
            chosenBirthDate,
            true,
            contact.phones.isNotEmpty ? contact.phones.first.number : "");
      }
    }
TomerPacific commented 2 months ago

@joachim-quis - any update here? Also tried on a Pixel7 physical device and saw the same behavior.

AbhishekSingh-958 commented 2 months ago

@TomerPacific Try using this line " await FlutterContacts.getContacts(withProperties: true); " . Set "withProperties: true ". I tested it on real device.

TomerPacific commented 2 months ago

@AbhishekSingh-958 - You are correct. This should be documented more clearly.