Browse SDKs · Flutter
Platform
SDKsFlutter

Create a text message

Create a text message with the OpenIM Flutter SDK.

Copy

Construct a plain text message object ready for delivery:

Parameters

ParameterTypeRequiredDescription
textStringYesBody content of the text message. We recommend validating length and trimming whitespace before passing.

Code example

final message = await OpenIM.iMManager.messageManager
    .createTextMessage(text: text.trim());

Return value

Returns a Future resolving to a Message object ready for transmission. Its contentType is set to the text message type, and its payload is stored in textElem.

State changes after the call

Creating a message only constructs the local message data structure in memory; it does not perform network transmission and does not trigger new-message event callbacks. Once created, pass the Message instance to Send a message to deliver it to a direct or group conversation.