Chat
Install Dependency
Package: meeting_place_chat
dart pub add meeting_place_chatYou can check the latest version of this module on the pub.dev or view the source code at the GitHub repository.
Classes and Methods
ChatSDK
The ChatSDK is a high-level API for secure messaging in the Meeting Place ecosystem. It wraps either a group or individual chat implementation based on the channel type and provides methods to send and receive messages, manage chat sessions, handle reactions, update contact details, and interact with mediator events. Built on top of the core Meeting Place SDK, it uses Decentralized Identifiers (DID) and the DIDComm v2.1 protocol to ensure private, end-to-end encrypted communication.
initialiseFromChannel
A static method that creates an instance of ChatSDK based on the type of channel provided. The type of Chat SDK created by this method depends on the channel type.
Parameters
channel [Channel]
The Channel entity representing the chat.
coreSDK [MeetingPlaceCoreSDK]
Instance of MeetingPlaceCoreSDK to retrieve group information if needed.
chatRepository [ChatRepository]
The ChatRepository used for persisting messages.
options [ChatSDKOptions]
Configuration options for the chat.
vCard [VCard]
Optional VCard representing the user profile.
logger [ChatSDKLogger]
Optional logger implementation for custom logging behavior.
Example
import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:meeting_place_chat/meeting_place_chat.dart';
// create a channel instance with type group
final Channel channel = Channel(
type: ChannelType.group,
permanentChannelDid: 'did:example:123',
otherPartyPermanentChannelDid: 'did:example:456',
mediatorDid: 'did:example:mediator',
offerLink: 'offer-link-value',
// ...other required fields
);
final chatSDK = await ChatSDK.initialiseFromChannel(
channel,
coreSDK: coreSDK,
chatRepository: await ref.read(chatItemsRepositoryDriftProvider.future),
options: ChatSDKOptions(presenceExpiresInSeconds: 3),
vCard: identityVcard
);startChatSession
Starts a new chat session.
- Initializes ChatStreamManager.
- Subscribes to the mediator channel.
- Loads persisted messages from repository.
- Triggers a profile hash sync.
Parameters
No Parameters Required
Example
import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:meeting_place_chat/meeting_place_chat.dart';final chatSDK = await ChatSDK.initialiseFromChannel(
...
);
final startSession = await chatSDK.start();endChatSession
Ends the chat session, disposing of the channel and stream manager.
Parameters
No Parameters Required
Example
import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:meeting_place_chat/meeting_place_chat.dart';
chatSDK.endChatSession();getMessageById
Retrieves a single message by ID.
Parameters
messageId [String]
A unique message identifier.
Example
import 'package:meeting_place_chat/meeting_place_chat.dart';
final messageId = '<MESSAGE-ID>';
final ChatItem? message = await chatSDK.getMessageById(messageId);fetchNewMessages
Fetches new messages from the channel.
Parameters
No Parameters Required
Example
import 'package:meeting_place_chat/meeting_place_chat.dart';
final List<Message> newMessages = await chatSDK.fetchNewMessages();sendProfileHash
Sends a profile hash update if the vCard has changed.
Parameters
No Parameters Required
Example
import 'package:meeting_place_chat/meeting_place_chat.dart';
await chatSDK.sendProfileHash();sendChatContactDetailsUpdate
Sends updated contact details from the current vCard.
Parameters
message [ConciergeMessage]
Message of updated contact details.
Example
import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:meeting_place_chat/meeting_place_chat.dart';
final ConciergeMessage updateMessage = ConciergeMessage(
chatId: '<CHAT-ID>',
messageId: '<MESSAGE-ID>',
senderDid: '<YOUR-DID>',
isFromMe: true,
// ...other required fields
);
await chatSDK.sendChatContactDetailsUpdate(updateMessage);sendTextMessage
Sends a plain text message (optionally with attachments).
Parameters
text [String]
The message content.
attachments [List<Attachment>]
An optional list of attachments
Example
import 'package:meeting_place_chat/meeting_place_chat.dart';
final Message sentMessage = await chatSDK.sendTextMessage(
'Hello, this is a test message!',
);reactOnMessage
Reacts (or unreacts) to a chat message with an emoji or symbol.
Parameters
message [Message]
The target message.
reaction [String]
The reaction string (e.g., emoji).
Example
import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:meeting_place_chat/meeting_place_chat.dart';
await chatSDK.reactOnMessage(message, reaction: reaction);sendChatActivity
Sends a chat activity message.
Parameters
No Parameters Required
Example
import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:meeting_place_chat/meeting_place_chat.dart';
await chatSDK.sendChatActivity();sendChatPresence
Sends a “chat presence” signal (e.g., online status).
Parameters
No Parameters Required
Example
import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:meeting_place_chat/meeting_place_chat.dart';
await chatSDK.sendChatPresence();sendEffect
Sends a special chat effect.
Parameters
effect [Effect]
The effect to send.
Possible values defined in enum are as follows: confetti, balloons, fireworks, hearts.
Example
import 'package:meeting_place_chat/meeting_place_chat.dart';
// Send confetti effect
await chatSDK.sendEffect(Effect.confetti);sendChatDeliveredMessage
Sends a “delivered” acknowledgement for a received message.
Parameters
message [PlainTextMessage]
The target message.
Example
import 'package:meeting_place_chat/meeting_place_chat.dart';
import 'package:didcomm/didcomm.dart';
final PlainTextMessage deliveredMessage = PlainTextMessage(
id: '<MESSAGE-ID>',
body: 'Hello, this is a sample message!',
// ...other required fields
);
// Send a "delivered" receipt for the message
await chatSDK.sendChatDeliveredMessage(deliveredMessage);subscribeToMediator
Subscribes to mediator events for the chat.
Parameters
No Parameters Required
Example
import 'package:meeting_place_chat/meeting_place_chat.dart';
final MediatorStream mediatorStream = await chatSDK.subscribeToMediator();approveConnectionRequest
Approves an incoming connection request.
Parameters
message [ConciergeMessage ]
A special type of ChatItem used to represent system or administrative messages that require user action.
Example
import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:meeting_place_chat/meeting_place_chat.dart';
await chatSDK.approveConnectionRequest(message);rejectConnectionRequest
A special type of ChatItem used to represent system or administrative messages that require user action.
Parameters
message [ConciergeMessage]
The ConciergeMessage requesting approval.
Example
import 'package:meeting_place_chat/meeting_place_chat.dart';
await chatSDK.rejectConnectionRequest(message);rejectChatContactDetailsUpdate
Rejects a contact details update and marks message as confirmed.
Parameters
message [ConciergeMessage]
The ConciergeMessage rejecting details update.
Example
import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:meeting_place_chat/meeting_place_chat.dart';
await chatSDK.rejectChatContactDetailsUpdate(message);messages
Retrieves all persisted messages for this chat.
Parameters
No Parameters Required
Example
import 'package:meeting_place_core/meeting_place_core.dart';
import 'package:meeting_place_chat/meeting_place_chat.dart';
final List<ChatItem> chatItems = await chatSDK.messages;chatStreamSubscription
Waits until the mediator channel subscription is ready. Stream of live chat events ([StreamData]) for this session.
Parameters
No Parameters Required
Example
import 'package:meeting_place_chat/meeting_place_chat.dart';
final ChatStream? chatStream = await chatSDK.chatStreamSubscription;Glad to hear it! Please tell us how we can improve more.
Sorry to hear that. Please tell us how we can improve.
Thank you for sharing your feedback so we can improve your experience.