getMessageDetails static method
Future<BaseMessage?>
getMessageDetails(
- int messageId, {
- dynamic onSuccess(
- BaseMessage? message
- dynamic onError(
- CometChatException excep
Implementation
static Future<BaseMessage?> getMessageDetails(
int messageId, {
Function(BaseMessage? message)? onSuccess,
Function(CometChatException excep)? onError,
}) async {
try {
// Use native Dart implementation via MessageRepository
if (!SdkRegistry.isInitialized()) {
throw StateError('SDK not initialized. Call CometChat.init() first.');
}
final sdk = SdkRegistry.getInstance();
final message = await sdk.messages.getMessageDetails(messageId.toString());
// Call the callback if provided
if (onSuccess != null) onSuccess(message);
return message;
} on StateError catch (e) {
debugPrint("Error: $e");
_errorCallbackHandler(
CometChatException(
ErrorCode.errorUserNotLoggedIn,
e.toString(),
'SDK not initialized',
),
null,
null,
onError,
);
} on PlatformException catch (p) {
debugPrint("Error: $p");
_errorCallbackHandler(null, p, null, onError);
} catch (e) {
debugPrint("Error: $e");
_errorCallbackHandler(null, null, e, onError);
}
return null;
}