listGroupIds method
fetches all the group Ids as a list on success return List of Group Ids otherwise []
Implementation
@override
Future<List<String?>> listGroupIds() async {
var atKey = _formKey(KeyType.groupList, isGet: true);
if (_regexType == RegexType.all) {
var scanList = await atClient!.getAtKeys(regex: atKey.key);
atKey = scanList.isNotEmpty ? _formAtKeyFromScanKeys(scanList[0]) : atKey;
}
var result = await atClient!.get(atKey);
//check for old key if new key data is not present.
if (result.value == null) {
atKey = _formKey(KeyType.groupList, isOld: true);
result = await atClient!.get(atKey);
}
//migrate key to new keyformat.
if (result.value != null && _isOldKey(atKey)) {
var newAtKey = _formKey(KeyType.groupList);
await atClient!.put(newAtKey, result.value);
result = await atClient!.get(newAtKey);
if (result.value != null) await atClient!.delete(atKey);
}
// get name from AtGroupBasicInfo for all the groups.
List<dynamic>? list = [];
list = (result.value != null) ? jsonDecode(result.value) : [];
list = List<String>.from(list!);
var groupIds = <String?>[];
list.forEach((group) {
var groupInfo = AtGroupBasicInfo.fromJson(jsonDecode(group));
groupIds.add(groupInfo.atGroupId);
});
return groupIds;
}