transferGroupOwnership static method
Future<String?>
transferGroupOwnership({
- required String guid,
- required String uid,
- required dynamic onSuccess(
- String result
- required dynamic onError(
- CometChatException excep
Transfers group ownership to another member.
Migration Note: Migrated from platform channels to native Dart. Behavior and signature remain identical.
Android Reference: GroupsRequest.transferOwnership(String guid, String uid)
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 {
// Get SDK instance
final sdk = SdkRegistry.getInstance();
// Call repository
await sdk.groups.transferOwnership(guid, uid);
// Call success callback
final result = 'Ownership transferred successfully';
if (onSuccess != null) onSuccess(result);
return result;
} on SdkException catch (sdkEx) {
// Convert SdkException to CometChatException
final cometChatEx = CometChatException(
sdkEx.code,
sdkEx.details ?? sdkEx.message,
sdkEx.message,
);
_errorCallbackHandler(cometChatEx, null, null, onError);
} catch (e) {
// Handle unexpected errors
_errorCallbackHandler(null, null, e, onError);
}
return null;
}