getContactsForPhone static method

Future<List<Contact>> getContactsForPhone(
  1. String? phone, {
  2. bool withThumbnails = true,
  3. bool photoHighResolution = true,
  4. bool orderByGivenName = true,
  5. bool iOSLocalizedLabels = true,
  6. bool androidLocalizedLabels = true,
})

Fetches all contacts, or when specified, the contacts with the phone matching phone

Implementation

static Future<List<Contact>> getContactsForPhone(String? phone,
    {bool withThumbnails = true,
    bool photoHighResolution = true,
    bool orderByGivenName = true,
    bool iOSLocalizedLabels = true,
    bool androidLocalizedLabels = true}) async {
  if (phone == null || phone.isEmpty) return List.empty();

  Iterable contacts =
      await _channel.invokeMethod('getContactsForPhone', <String, dynamic>{
    'phone': phone,
    'withThumbnails': withThumbnails,
    'photoHighResolution': photoHighResolution,
    'orderByGivenName': orderByGivenName,
    'iOSLocalizedLabels': iOSLocalizedLabels,
    'androidLocalizedLabels': androidLocalizedLabels,
  });
  return contacts.map((m) => Contact.fromMap(m)).toList();
}