getContact static method

Future<Contact?> getContact(
  1. String id, {
  2. bool withProperties = true,
  3. bool withThumbnail = true,
  4. bool withPhoto = true,
  5. bool withGroups = false,
  6. bool withAccounts = false,
  7. bool deduplicateProperties = true,
})

Fetches one contact.

By default everything available is fetched. If withProperties is false, properties (phones, emails, addresses, websites, etc) won't be fetched.

If withThumbnail is false, the low-resolution thumbnail won't be fetched. If withPhoto is false, the high-resolution photo won't be fetched.

If withGroups is true, it also returns the group information (called labels on Android and groups on iOS).

If withAccounts is true, it also returns the account information. On Android this is the raw account, and there can be several accounts per unified contact (for example one for Gmail, one for Skype and one for WhatsApp). On iOS it is called container, and there can be only one container per contact.

If deduplicateProperties is true, the properties will be de-duplicated, mainly to avoid the case (common on Android) where multiple equivalent phones are returned.

Implementation

static Future<Contact?> getContact(
  String id, {
  bool withProperties = true,
  bool withThumbnail = true,
  bool withPhoto = true,
  bool withGroups = false,
  bool withAccounts = false,
  bool deduplicateProperties = true,
}) async {
  final contacts = await _select(
    id: id,
    withProperties: withProperties,
    withThumbnail: withThumbnail,
    withPhoto: withPhoto,
    withGroups: withGroups,
    withAccounts: withAccounts,
    sorted: false,
    deduplicateProperties: deduplicateProperties,
  );
  if (contacts.length != 1) return null;
  return contacts.first;
}