deleteConversation method

Future<bool> deleteConversation(
  1. String conversationId,
  2. {bool deleteMessages = true}
)

Deletes a conversation and its related messages from the local database.

If you set deleteMessages to true, the local historical messages are deleted when the conversation is deleted.

Param conversationId The conversation ID.

Param deleteMessages Whether to delete the historical messages when deleting the conversation.

  • true: (default) Yes.
  • false: No.

Return Whether the conversation is successfully deleted.

  • true: Yes;
  • false: No.

Throws A description of the exception. See ChatError.

Implementation

Future<bool> deleteConversation(
  String conversationId, {
  bool deleteMessages = true,
}) async {
  Map req = {"convId": conversationId, "deleteMessages": deleteMessages};
  Map result =
      await ChatChannel.invokeMethod(ChatMethodKeys.deleteConversation, req);
  try {
    ChatError.hasErrorFromResult(result);
    return result.boolValue(ChatMethodKeys.deleteConversation);
  } on ChatError catch (e) {
    throw e;
  }
}