deleteGroup static method

Future<void> deleteGroup(
  1. String guid, {
  2. required dynamic onSuccess(
    1. String message
    )?,
  3. required dynamic onError(
    1. CometChatException excep
    )?,
})

In order to delete a group.

The user must be an Admin of the group they are trying to delete.

guid A unique identifier for a group that logged in user wants to delete.

method could throw PlatformException with error codes specifying the cause

Implementation

static Future<void> deleteGroup(String guid, {required Function(String message)? onSuccess, required Function(CometChatException excep)? onError}) async {
  try {
    var result = await channel.invokeMethod('deleteGroup', {
      'guid': guid,
    });
    if(onSuccess != null) onSuccess(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()));
  }
}