myGetContacts function

Future<List<Contact>> myGetContacts()

Implementation

Future<List<Contact>> myGetContacts() async {
  Iterable<Contact> entries = await FlutterContacts.getContacts(
    withProperties: true,
    withThumbnail: false,
    withPhoto: false,
    withGroups: false,
    withAccounts: false,
  );


  List<Contact> contactsWithPhones = entries.where((contact) => contact.phones.isNotEmpty).map((contact) {
    contact.displayName = contact.displayName;
    return contact;
  }).toList();
  return contactsWithPhones;
}