addGroupMembers method

void addGroupMembers(
  1. String groupId, {
  2. required List<String> membersToAdd,
  3. List<String> adminsToSet = const [],
  4. SealdGeneratedPrivateKeys? privateKeys,
})

Adds members to a group. Can only be done by a group administrator. Can also specify which of these newly added group members should also be admins.

groupId - The group in which to add members. membersToAdd - The Seald IDs of the members to add to the group. adminsToSet - The Seald IDs of the newly added members to also set as group admins. privateKeys - Optional. Pre-generated private keys, returned by a call to SealdSdk.generatePrivateKeysAsync.

Implementation

void addGroupMembers(String groupId,
    {required List<String> membersToAdd,
    List<String> adminsToSet = const [],
    SealdGeneratedPrivateKeys? privateKeys}) {
  if (_closed) {
    throw SealdException(
        code: "INSTANCE_CLOSED",
        id: "FLUTTER_INSTANCE_CLOSED",
        description: "Instance already closed.");
  }
  if (_shouldRenewGroup(groupId)) {
    renewGroupKey(groupId, privateKeys: privateKeys);
  }
  final Pointer<Utf8> nativeGroupId = groupId.toNativeUtf8();
  final Pointer<NativeSealdStringArray> nativeMembersToAdd =
      _sealdStringArrayFromList(membersToAdd);
  final Pointer<NativeSealdStringArray> nativeAdminsToSet =
      _sealdStringArrayFromList(adminsToSet);
  final Pointer<Pointer<NativeSealdError>> err =
      calloc<Pointer<NativeSealdError>>();

  final int resultCode = _bindings.SealdSdk_AddGroupMembers(_ptr.pointer(),
      nativeGroupId, nativeMembersToAdd, nativeAdminsToSet, err);

  calloc.free(nativeGroupId);
  _bindings.SealdStringArray_Free(nativeMembersToAdd);
  _bindings.SealdStringArray_Free(nativeAdminsToSet);

  if (resultCode != 0) {
    throw SealdException._fromCPtr(err);
  } else {
    calloc.free(err);
  }
}