getMessageDetails static method
Future<BaseMessage?>
getMessageDetails(
- int messageId, {
- dynamic onSuccess()?,
- dynamic onError(
- CometChatException excep
Fetches a single message by messageId.
The fetch carries withThreadSubscribed=true, so the returned message's
BaseMessage.threadSubscribed reflects the logged-in user's
subscription state for its thread — this is the fetch the thread
row-insert recipe builds on (fetch the root message, build the row,
insert at the head, mark it seen on the active ThreadsRequest).
Implementation
static Future<BaseMessage?> getMessageDetails(int messageId,
{Function(BaseMessage message)? onSuccess,
Function(CometChatException e)? onError}) async {
try {
final sdk = SdkRegistry.getInstance();
final message =
await sdk.messages.getMessageDetails(messageId.toString());
if (onSuccess != null) onSuccess(message);
return message;
} on SdkException catch (sdkEx) {
final cometChatEx = CometChatException(
sdkEx.code,
sdkEx.details ?? sdkEx.message,
sdkEx.message,
);
_errorCallbackHandler(cometChatEx, null, null, onError);
} catch (e) {
_errorCallbackHandler(null, null, e, onError);
}
return null;
}