addGroupContact method
Implementation
addGroupContact(GroupContactsModel? item) {
try {
var isSelected = false;
length = 0;
if (selectedGroupContacts.isNotEmpty) {
for (var groupContact in selectedGroupContacts) {
if (groupContact!.contactType == ContactsType.CONTACT) {
length++;
} else if (groupContact.contactType == ContactsType.GROUP) {
length = length + groupContact.group!.members!.length;
}
}
}
// ignore: omit_local_variable_types
for (GroupContactsModel? groupContact in selectedGroupContacts) {
if ((item.toString() == groupContact.toString())) {
isSelected = true;
break;
} else {
isSelected = false;
}
}
if (length <= 25 && !isSelected) {
selectedGroupContacts.add(item);
}
if (item!.contactType == ContactsType.CONTACT) {
length++;
} else if (item.contactType == ContactsType.GROUP) {
length += item.group!.members!.length;
}
selectedContactsSink.add(selectedGroupContacts);
} catch (e) {
selectedContactsSink.add([]);
}
}