removeReaction static method

Future<BaseMessage?> removeReaction(
  1. int messageId,
  2. String reaction, {
  3. dynamic onSuccess(
    1. BaseMessage
    )?,
  4. dynamic onError(
    1. CometChatException
    )?,
})

addReaction will remove a reaction to a message with the provided message ID and will update the UI of CometChatMessageList and CometChatReactions accordingly

Implementation

static Future<BaseMessage?> removeReaction(
  int messageId,
  String reaction, {
  dynamic Function(BaseMessage)? onSuccess,
  dynamic Function(CometChatException)? onError,
}) async {
  final message = await CometChat.removeReaction(messageId, reaction,
      onSuccess: (reactedMessage) {
    //executing the custom onSuccess handler
    if (onSuccess != null) {
      try {
        onSuccess(reactedMessage);
      } catch (e) {
        if (kDebugMode) {
          debugPrint("failed to execute onSuccess callback");
        }
      }
    }

    CometChatMessageEvents.ccMessageEdited(
        reactedMessage, MessageEditStatus.success);
  }, onError: (error) {
    //executing the custom onError handler
    if (onError != null) {
      try {
        onError(error);
      } catch (e) {
        if (kDebugMode) {
          debugPrint("failed to execute onError callback");
        }
      }
    }
  });

  return message;
}