getAllGroupsDetails method
dynamic
getAllGroupsDetails({})
Implementation
getAllGroupsDetails({
int? expandIndex,
AtGroup? expandGroup,
bool addToGroupSink = true,
}) async {
try {
var groupIds = await atContactImpl.listGroupIds();
var groupList = <AtGroup>[];
for (var i = 0; i < groupIds.length; i++) {
var groupDetail = await (getGroupDetail(groupIds[i]!));
if (groupDetail != null) groupList.add(groupDetail);
}
for (AtGroup group in groupList) {
var index =
allContacts.indexWhere((element) => element!.group != null && element.group!.groupId == group.groupId);
if (index == -1) {
allContacts.add(GroupContactsModel(group: group, contactType: ContactsType.GROUP));
}
}
if (expandIndex != null) {
this.expandIndex = expandIndex;
} else {
if (expandGroup != null) {
this.expandIndex = groupList.indexWhere((element) => element.groupId == expandGroup.groupId);
} else {
this.expandIndex = 0;
}
}
if (addToGroupSink) {
atGroupSink.add(groupList);
}
} catch (e) {
atGroupSink.add([]);
}
}