Set a conversation draft
Save a conversation draft with setConversationDraft in the OpenIM Flutter SDK.
Use setConversationDraft() to save a conversation draft when the user leaves a chat page, switches conversations, or changes the editor content. While the user is typing, keep the editor state locally and debounce save calls. Submit the latest text once more immediately before leaving the page.
await OpenIM.iMManager.conversationManager.setConversationDraft(
conversationID: conversationID,
draftText: editorValue,
);Pass an empty string to clear the draft:
await OpenIM.iMManager.conversationManager.setConversationDraft(
conversationID: conversationID,
draftText: '',
);State after the call
A successful Future means only that this save request completed; it does not mean the conversation-change callback has arrived. The SDK can subsequently report the updated List<ConversationInfo> through onConversationChanged. Merge draftText and draftTextTime by conversationID, and query the conversation again when reconciliation is needed. Request completion, event arrival, and a new query are three separate stages. For complete event handling, see Retrieve the conversation list. Also clear in-memory editor state when the user logs out or switches accounts.
Was this page helpful?