/ SDKs / Flutter
SDKs
Chat SDKs Flutter v3
Chat SDKs Flutter
Chat SDKs
Flutter
Version 3
Sendbird Chat SDK v3 for Flutter is no longer supported as a new version is released. Check out our latest Chat SDK v4

Create a message thread

Copy link

When a user replies to a message in a channel, it creates a message thread, which refers to a collection of messages consisting of a parent message and its replies. Message threading lets users ask questions, give feedback, or add context to a specific message without disrupting the flow of conversation. It can have the following elements.

  • A message can have a thread of replies.

  • A message that has a thread of replies is a parent message.

  • A parent message and its threaded replies are collectively called a message thread.

  • Every message within a thread, whether it's parent or reply, is a threaded message.

  • A message that doesn't have any replies is an unthreaded message.

Message threading has the following limitations.

  • Only 1-depth threads are supported, meaning you can only add reply messages to non-reply messages. You can't add a reply to a reply message.

  • Message threading is limited to text and file messages. You can't send admin messages as replies or add replies to admin messages.

You can reply to a specific message in a channel through the sendUserMessage() or sendFileMessage() method. To do so, you should create a UserMessageParams or a FileMessageParams object and then specify the parentMessageId property of the object. Sending reply messages works the same way as sending regular messages to a channel except replies have an additional parentMessageId property.


Reply with a text message

Copy link

When replying to a message through the sendUserMessage() method, you should specify and pass a UserMessageParams object to the method as a parameter. The UserMessageParams class is derived from the BaseMessageParams class and can access all the methods and properties of BaseMessageParams.

try {
    final params = UserMessageParams(message: MESSAGE)
        ..parentMessageId = PARENT_MESSAGE_ID;

    final result = await channel.sendUserMessage(params);
    // A reply to a specific message in the form of a text message is successfully sent.
} catch (e) {
    // Handle error.
}

UserMessageParams

Copy link

This table only contains properties shown in the code above. To see the comprehensive list of all available methods and properties, see UserMessageParams.

Property nameTypeDescription

parentMessageId

int

Specifies the unique ID of a parent message which has a thread of replies. If the message sent through the sendUserMessage() method is a parent message, the value of this property is set to 0. If the message is a reply to a parent message, the value is the message ID of the parent message.

message

string

Specifies the message to send.

replyToChannel

boolean

Determines whether to send the message to the channel as well. To use this property, the value of parentMessageId must be specified. (Default: false)


Reply with a file message

Copy link

When replying with a file message through the sendFileMessage() method, you should specify and pass a FileMessageParams object to the method as a parameter. The FileMessageParams class is derived from the BaseMessageParams class and can access all the methods and properties of BaseMessageParams.

try {
    final params = FileMessageParams.withFile(file, name: ‘FILE_NAME’)
        ..parentMessageId = PARENT_MESSAGE_ID;

    final result = await channel.sendFileMessage(params);
    // A reply to a specific message is successfully sent in the form of a file message.
} catch (e) {
    // Handle error.
}

FileMessageParams

Copy link

This table only contains properties shown in the code above. To see the comprehensive list of all available methods and properties, see FileMessageParams.

Property nameTypeDescription

parentMessageId

int

Specifies the unique ID of a parent message which has a thread of replies. If the message sent through the sendFileMessage() method is a parent message, the value of this property is set to 0. If the message is a reply to a parent message, the value is the message ID of the parent message.

file

File

Specifies the binary file data. When the value of file is specified, the value of fileUrl can't be specified. (Default: null)

fileName

string

Specifies the file name. (Default: null)

mimeType

string

Specifies the file MIME type. (Default: null)

fileSize

int

Specifies the file size. (Default: null)