addReaction static method
Future<BaseMessage?>
addReaction(})
addReaction will add a reaction to a message with the provided message ID and will update the UI of CometChatMessageList
and CometChatReactions
accordingly
Implementation
static Future<BaseMessage?> addReaction(
int messageId,
String reaction, {
dynamic Function(BaseMessage)? onSuccess,
dynamic Function(CometChatException)? onError,
}) async {
final message = await CometChat.addReaction(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;
}