Chat / Flutter
Current version: v3
Chat Flutter v3
Chat Flutter
Chat
Flutter
Home
/
Chat
/
Flutter
/
Message

Retrieve a message

You can retrieve a specific message in an open or group channel by creating and passing the MessageRetrievalParams object as an argument into the getMessage() method.

Note: Starting from Flutter Chat SDK 3.1.0, MessageRetrievalParams requires the channelType, channelUrl, and messageId parameters.

try {
    // Create a MessageRetrievalParams object.
    final params = MessageRetrievalParams(
        messageId: MESSAGE_ID
        channelType: ChannelType.open
        channelUrl: CHANNEL_URL
    );

    // Pass the params to the parameter of the getMessage() method.
    final message = await BaseMessage.getMessage(params);
    // The specified message is successfully retrieved.
} catch (e) {
    // Handle error.
}

List of properties

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

Property nameTypeDescription

channelUrl

String

Specifies the URL of the channel.

channelType

ChannelType

Specifies the type of the channel.

messageId

Int

Specifies the unique ID of the message.


Retrieve the last message of a group channel

You can retrieve and view the last message of a group channel.

final lastMessage = groupChannel.lastMessage;