Browse SDKs · Flutter
Platform
SDKsFlutter

Send a message

Use the Flutter SDK to send a prepared message object.

Copy

Deliver a constructed message object to a direct or group conversation. If the message references local media files, the SDK automatically uploads the files and delivers the message:

Parameters

ParameterTypeRequiredDescription
messageMessageYesThe prepared message object constructed using a factory method.
userIDString?Required for single chatRecipient user ID in direct chats. Omit when sending group messages.
groupIDString?Required for group chatTarget group ID in group chats. Omit when sending direct messages.
offlinePushInfoOfflinePushInfo?NoCustom offline push notification settings (title, description, and passthrough data).
isOnlineOnlyboolNoWhether the message is online-only; defaults to false. When true, the message is not persisted to local storage or cloud roaming history.

Code example

final sent = await OpenIM.iMManager.messageManager.sendMessage(
  message: message,
  userID: receiverUserID,
  offlinePushInfo: offlinePushInfo,
);

Set only userID for direct chats, and set only groupID for group chats. These parameters are mutually exclusive; never supply both.

Return value

Returns a Future resolving to the server-confirmed Message object. Update the delivery status and server timestamp of the pending message in your local UI list using its non-empty clientMsgID.

State changes after the call

If sending images, audio, or video created from local filesystem paths, the SDK automatically handles media uploading during transmission. To track upload progress callbacks, see Set message send progress listener. When media files have already been uploaded by your application server and URLs are available, use Send a message without OSS to bypass SDK upload pipelines.