getMessageReceipts static method

Future<List<MessageReceipt>?> getMessageReceipts(
  1. int messageId, {
  2. required dynamic onSuccess(
    1. List<MessageReceipt> messageReceipt
    )?,
  3. required dynamic onError(
    1. CometChatException excep
    )?,
})

Method to get message receipts.

method could throw PlatformException with error codes specifying the cause

Implementation

static Future<List<MessageReceipt>?> getMessageReceipts(int messageId, {required Function(List<MessageReceipt> messageReceipt)? onSuccess, required Function(CometChatException excep)? onError}) async {
  try {
    List<MessageReceipt> receiptList = [];
    final result = await channel.invokeMethod('getMessageReceipts', {'id': messageId});
    for (var _obj in result) {
      try {
        receiptList.add(MessageReceipt.fromMap(_obj));
      } catch (e) {
        if(onError != null) onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
        return [];
      }
    }
    if(onSuccess != null) onSuccess(receiptList);
    return receiptList;
  } on PlatformException catch (platformException) {
    if(onError != null) onError(CometChatException(platformException.code, platformException.details, platformException.message));
  } catch (e) {
    debugPrint("Error: $e");
    if(onError != null) onError(CometChatException(ErrorCode.errorUnhandledException, e.toString() , e.toString()));
  }
  return null;
}