getJoinedGroups method Null safety

Future<List<EMGroup>> getJoinedGroups()

Gets all groups of the current user from the cache.

Return The group list.

Throws A description of the exception. See {@link EMError}.

Implementation

Future<List<EMGroup>> getJoinedGroups() async {
  Map result = await _channel.invokeMethod(ChatMethodKeys.getJoinedGroups);
  try {
    EMError.hasErrorFromResult(result);
    List<EMGroup> list = [];
    result[ChatMethodKeys.getJoinedGroups]
        ?.forEach((element) => list.add(EMGroup.fromJson(element)));
    return list;
  } on EMError catch (e) {
    throw e;
  }
}