addReaction static method
Future<BaseMessage?>
addReaction(
- int messageId,
- String reaction, {
- required dynamic onSuccess()?,
- required dynamic onError(
- CometChatException excep
Add a reaction to a message.
The messageId
parameter specifies the ID of the message to add the reaction to.
The reaction
parameter specifies the reaction to add.
The onSuccess
function is called with the added BaseMessage when the reaction is added successfully.
The onError
function is called with a CometChatException object when there is an error while adding the reaction.
Returns a Future that resolves to the added BaseMessage or null if there was an error.
Implementation
static Future<BaseMessage?> addReaction(int messageId, String reaction,
{required Function(BaseMessage)? onSuccess,
required Function(CometChatException excep)? onError}) async {
try {
final result = await channel.invokeMethod(
'addReaction', {'messageId': messageId, 'reaction': reaction});
final BaseMessage res = BaseMessage.fromMap(result);
if (onSuccess != null) onSuccess(res);
return res;
} on PlatformException catch (p) {
_errorCallbackHandler(null, p, null, onError);
} catch (e) {
_errorCallbackHandler(null, null, e, onError);
}
return null;
}