transferGroupOwnership static method

Future<String?> transferGroupOwnership({
  1. required String guid,
  2. required String uid,
  3. required dynamic onSuccess(
    1. String result
    )?,
  4. required dynamic onError(
    1. CometChatException excep
    )?,
})

Transfer the ownership of any group if logged-in user is the owner of the group

guid The GUID of the group for which the ownership needs to be changed

uid The UID of the member who should be the new owner

method could throw PlatformException with error codes specifying the cause

Implementation

static Future<String?> transferGroupOwnership({
  required String guid,
  required String uid,
  required Function(String result)? onSuccess,
  required Function(CometChatException excep)? onError}
) async {
  try {
    final result = await channel.invokeMethod('transferGroupOwnership', {
      'guid': guid,
      'uid': uid,
    });
    if(onSuccess != null) onSuccess(result);
    return result;
  } on PlatformException catch (platformException) {
    if(onError != null) onError(CometChatException(platformException.code, platformException.details, platformException.message));
  } catch (e) {
    debugPrint("Error: $e");
    if(onError != null) onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
  }
  return null;
}