Browse SDKs · Flutter
Platform
SDKsFlutter

Set conversation draft

Save or clear unsent message text drafts for a conversation using the OpenIM Flutter SDK.

Copy

When a user leaves a chat screen, switches channels, or pauses typing, persist the unsent draft text for that conversation. Maintain editor state locally while typing, debounce persistence calls, and commit the latest text immediately before navigating away.

Parameters

ParameterTypeRequiredDescription
conversationIDStringYesTarget conversation ID.
draftTextStringYesDraft text content. Pass an empty string '' to clear the draft.

Code example

await OpenIM.iMManager.conversationManager.setConversationDraft(
  conversationID: conversationID,
  draftText: editorValue,
);

Clear the draft by supplying an empty string:

await OpenIM.iMManager.conversationManager.setConversationDraft(
  conversationID: conversationID,
  draftText: '',
);

Return value

A successful Future indicates that the draft has been written to the local conversation database.

State changes after the call

Multi-device synchronization and arriving changes trigger conversation change events. The client uses conversationID as the merge key to update draftText and draftTextTime on the local conversation model. For complete listener integration, see Retrieve conversation list. Purge in-memory editor states when logging out or switching user accounts.