clearChat method

  1. @override
Future<void> clearChat(
  1. String jid,
  2. String chatType,
  3. bool clearExceptStarred,
  4. dynamic callback(
    1. FlyResponse response
    )?,
)
override

This method is used to clear the chat of a user using JID.

Implementation

@override
Future<void> clearChat(String jid, String chatType, bool clearExceptStarred,
    Function(FlyResponse response)? callback) async {
  bool? clearChatResponse;
  try {
    clearChatResponse = await mirrorFlyMethodChannel.invokeMethod<bool>(
        'clear_chat', {
      "jid": jid,
      "chat_type": chatType,
      "clear_except_starred": clearExceptStarred
    });
    LogMessage.d("clearChat ", " $clearChatResponse");
    callback?.call(FlyResponse(true, FlyConstants.empty, FlyConstants.empty));
    // return clearChatResponse ?? false;
  } on PlatformException catch (e) {
    LogMessage.d("Platform Exception =", " $e");
    callback?.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
        FlyException(e.code, e.message, e.details)));
  } on Exception catch (e) {
    LogMessage.d("Exception ", " $e");
    callback?.call(FlyResponse(false, FlyConstants.empty, FlyConstants.empty,
        FlyException(FlyErrorCode.unHandle, FlyErrorMessage.unHandle, e)));
  }
}