removeGroupContact method
Implementation
removeGroupContact(GroupContactsModel? item) async {
try {
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 (groupContact!.contact != null &&
item!.contact != null &&
groupContact.contact!.atSign == item.contact!.atSign) {
var index = selectedGroupContacts.indexOf(groupContact);
selectedGroupContacts.removeAt(index);
break;
} else if (groupContact.group != null &&
item!.group != null &&
groupContact.group!.groupId == item.group!.groupId) {
var index = selectedGroupContacts.indexOf(groupContact);
selectedGroupContacts.removeAt(index);
break;
}
}
if (item!.contactType == ContactsType.CONTACT) {
length--;
} else if (item.contactType == ContactsType.GROUP) {
length -= item.group!.members!.length;
}
selectedContactsSink.add(selectedGroupContacts);
} catch (e) {
atSignLogger.severe('Error in removeGroupContact $e');
}
}