clearChat static method

Future<void> clearChat({
  1. required String jid,
  2. required String chatType,
  3. required bool clearExceptStarred,
  4. required dynamic flyCallBack(
    1. FlyResponse response
    ),
})

This method clears the chat history for the chat identified by jid and chatType. It can optionally preserve starred messages if clearExceptStarred is set to true.

Parameters: jid - The JID (Jabber ID) of the user or group whose chat history is to be cleared. chatType - The type of chat (e.g., "single", "group") to specify which chat's history to clear. clearExceptStarred - A boolean value indicating whether to clear all messages except starred ones.

Returns: A Future<void> that completes when the operation is finished.

Example usage:

await Mirrorfly.clearChat(
  jid: "user123@example.com",
  chatType: "groupchat" or "chat",
  clearExceptStarred: false,
  flyCallBack: (response) {
    if (response.isSuccess) {
      print("Chat cleared successfully");
    } else {
      print("Failed to clear chat: ${response.errorMessage}");
    }
  },
);

Implementation

static Future<void> clearChat(
    {required String jid,
    required String chatType,
    required bool clearExceptStarred,
    required Function(FlyResponse response) flyCallBack}) {
  return FlyChatFlutterPlatform.instance
      .clearChat(jid, chatType, clearExceptStarred, flyCallBack);
}