Insert a local one-to-one message
Use the Flutter SDK to insert a local message into a one-to-one conversation.
Insert a local placeholder or private message into a one-to-one chat history on the current device only, without performing network delivery:
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
receiverID | String | Yes | Target user ID of the recipient in the direct chat. |
senderID | String | Yes | User ID of the message sender (can be the current user or a virtual system user ID). |
message | Message | Yes | The complete message object to persist locally. |
Code example
final stored = await OpenIM.iMManager.messageManager
.insertSingleMessageToLocalStorage(
receiverID: receiverUserID,
senderID: senderUserID,
message: localMessage,
);While parameters are marked nullable in the underlying SDK declaration, you must supply non-empty values to guarantee correct conversation routing.
Return value
Returns a Future resolving to the persisted Message object. Merge it into your active one-to-one chat UI list using its non-empty clientMsgID.
State changes after the call
This operation modifies only the local database on the current device. It does not synchronize to the server, is not sent to the peer user, and does not emit cross-device event notifications. When real network delivery to the recipient is required, see Send a message; to insert a local message in a group chat, see Insert a local group message.
Was this page helpful?