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;
}
AtValue? result;
result = await _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 _get(atKey);
}
//migrate key to new keyformat.
if (result?.value != null && _isOldKey(atKey)) {
var newAtKey = _formKey(KeyType.groupList);
await atClient!.put(newAtKey, result?.value);
AtValue? getValue;
getValue = await _get(newAtKey);
// If old is migrated to new successfully, remove the old key
if (getValue?.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;
}