getGroupWithId method Null safety

Future<EMGroup?> getGroupWithId(
  1. String groupId
)

Gets the group instance from the cache by group ID.

Param groupId The group ID.

Return The group instance. Returns null if the group does not exist.

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

Implementation

Future<EMGroup?> getGroupWithId(String groupId) async {
  Map req = {'groupId': groupId};
  Map result =
      await _channel.invokeMethod(ChatMethodKeys.getGroupWithId, req);
  try {
    EMError.hasErrorFromResult(result);
    if (result.containsKey(ChatMethodKeys.getGroupWithId)) {
      return EMGroup.fromJson(result[ChatMethodKeys.getGroupWithId]);
    } else {
      return null;
    }
  } on EMError catch (e) {
    throw e;
  }
}