getUnreadMessageCount method Null safety

Future<int> getUnreadMessageCount()

Gets the count of the unread messages.

Return The count of the unread messages.

Throws A description of the exception. See {@link EMError}.

Implementation

Future<int> getUnreadMessageCount() async {
  Map result =
      await _channel.invokeMethod(ChatMethodKeys.getUnreadMessageCount);
  try {
    int ret = 0;
    EMError.hasErrorFromResult(result);
    if (result.containsKey(ChatMethodKeys.getUnreadMessageCount)) {
      ret = result[ChatMethodKeys.getUnreadMessageCount] as int;
    }
    return ret;
  } on EMError catch (e) {
    throw e;
  }
}