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]!));
// ignore: unnecessary_null_comparison
if (groupDetail != null) groupList.add(groupDetail);
}
groupList.forEach((AtGroup group) {
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) {
print('error in getting group list: $e');
}
}