addContactToList method

void addContactToList(
  1. AtContact _selectedContact
)

adds a contact to the contact list

Implementation

void addContactToList(AtContact _selectedContact) {
  var _containsContact = false;

  // to prevent one contact from getting added again
  // ignore: avoid_function_literals_in_foreach_calls
  EventService().selectedContacts!.forEach((_contact) {
    if (_selectedContact.atSign == _contact.atSign) {
      _containsContact = true;
    }
  });

  if (!_containsContact) {
    EventService()
        .eventNotificationModel!
        .group!
        .members!
        .add(_selectedContact);
    EventService().selectedContacts!.add(_selectedContact);
    selectedContactsAtSigns.add(_selectedContact.atSign);
  }
}