updateGroup static method

Future<Group?> updateGroup({
  1. required Group group,
  2. required dynamic onSuccess(
    1. Group group
    )?,
  3. required dynamic onError(
    1. CometChatException excep
    )?,
})

Updates group details.

Migration Note: Migrated from platform channels to native Dart. Behavior and signature remain identical.

Android Reference: GroupsRequest.updateGroup(Group group)

update the group details

guid an instance of class Group

method could throw PlatformException with error codes specifying the cause

Implementation

static Future<Group?> updateGroup(
    {required Group group,
    required Function(Group group)? onSuccess,
    required Function(CometChatException excep)? onError}) async {
  try {
    // Get SDK instance
    final sdk = SdkRegistry.getInstance();

    // Call repository
    final updatedGroup = await sdk.groups.updateGroup(group);

    // Call success callback
    if (onSuccess != null) onSuccess(updatedGroup);
    return updatedGroup;
  } 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;
}