/ SDKs / Flutter
SDKs
Chat SDKs Flutter v4
Chat SDKs Flutter
Chat SDKs
Flutter
Version 4

Retrieve a message

Copy link

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(
    channelType: ChannelType.open
    channelUrl: 'CHANNEL_URL'
    messageId: MESSAGE_ID
  );

  // 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

Copy link

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

channelType

ChannelType

Specifies the type of the channel.

channelUrl

String

Specifies the URL of the channel.

messageId

Int

Specifies the unique ID of the message.


Retrieve the last message of a group channel

Copy link

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

final lastMessage = groupChannel.lastMessage;