leaveGroup static method

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

In order to stop receiving updates and messages for any particular joined group.

Owner cannot leave the group , transfer the ownership before leaving the group

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

method could throw PlatformException with error codes specifying the cause

Implementation

static Future<void> leaveGroup(String guid,
    {required Function(String returnResponse)? onSuccess,
    required Function(CometChatException excep)? onError}) async {
  try {
    var result = await channel.invokeMethod('leaveGroup', {
      'guid': guid,
    });
    if (onSuccess != null) onSuccess(result);
    return result;
  } on PlatformException catch (p) {
    _errorCallbackHandler(null, p, null, onError);
  } catch (e) {
    _errorCallbackHandler(null, null, e, onError);
  }
}