markAsUnread static method

Future<void> markAsUnread(
  1. BaseMessage baseMessage,
  2. {required dynamic onSuccess(
    1. String
    )?,
  3. required dynamic onError(
    1. CometChatException excep
    )?}
)

Marks a BaseMessage as unread.

The markAsUnread function takes in a BaseMessage object, which represents the message you want to mark as unread.

Implementation

static Future<void> markAsUnread(BaseMessage baseMessage, {required Function(String)? onSuccess, required Function(CometChatException excep)? onError}) async {
  try {
    Map<String, dynamic> map = baseMessage.toJson();
    final result = await channel.invokeMethod('markAsUnread', {'baseMessage': map});
    if(onSuccess != null) onSuccess(result);
  } 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()));
  }
}