MockChatAdapter class

An in-memory ChatAdapter for use in tests and example apps.

All operations succeed immediately. No network calls are made. Incoming events can be simulated with the simulate* helper methods.

final adapter = MockChatAdapter();
final chat = await Chat.create(
  databasePath: ':memory:',
  adapter: adapter,
  identityProvider: StaticIdentityProvider('user-1'),
);
// Simulate an incoming message from another user:
adapter.simulateIncomingMessage(
  conversationId: 'room-1',
  senderId: 'user-2',
  content: 'Hello!',
);
Implemented types

Constructors

MockChatAdapter()

Properties

connectionState → Stream<ChatConnectionState>
no setteroverride
eventStream → Stream<ChatEvent>
no setteroverride
hashCode → int
The hash code for this object.
no setterinherited
isConnected → bool
Whether the adapter is currently connected.
no setteroverride
name → String
Adapter name for logging.
no setteroverride
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addParticipants(String conversationId, List<String> userIds) → Future<void>
override
addReaction(String messageId, String emoji) → Future<void>
override
archiveConversation(String conversationId) → Future<void>
override
connect() → Future<void>
override
createConversation(CreateConversationParams params) → Future<Conversation>
override
deleteConversation(String conversationId) → Future<void>
override
deleteMessage(String conversationId, String messageId) → Future<void>
override
disconnect() → Future<void>
override
dispose() → Future<void>
Dispose adapter resources.
override
getConversation(String conversationId) → Future<Conversation?>
override
getPendingRequests(String conversationId) → Future<List<Participant>>
override
getPinnedMessages(String conversationId) → Future<List<Message>>
override
getPresence(String userId) → Future<PresenceResult>
override
getStarredMessages() → Future<List<Message>>
override
getStarredMessagesByConversation(String conversationId) → Future<List<Message>>
override
incrementalSync(String sinceToken) → Future<SyncResult>
override
initialize() → Future<void>
Initialize the adapter (called once at startup).
override
initialSync() → Future<SyncResult>
override
loadMessages(String conversationId, {String? before, int? limit}) → Future<LoadMessagesResult>
override
markAsRead(String conversationId, String messageId) → Future<void>
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
pinMessage(String conversationId, String messageId, Duration? duration) → Future<void>
override
removeParticipant(String conversationId, String userId) → Future<void>
override
removeReaction(String messageId, String reactionId) → Future<void>
override
sendMessage(SendMessageParams params) → Future<Message>
override
sendTyping(String conversationId, {required bool isTyping}) → Future<void>
override
simulateConnectionState(ChatConnectionState state) → void
Simulate a connection state change.
simulateIncomingMessage({required String conversationId, required String senderId, required String content}) → void
Simulate an incoming message from another user.
starMessage(String conversationId, String messageId) → Future<String>
override
startHeartbeat(String userId, Duration interval) → void
Start presence heartbeat. Override in socket-based adapters.
override
stopHeartbeat() → void
Stop presence heartbeat. Override in socket-based adapters.
override
subscribePresence(String userId) → Future<void>
override
syncConversation(String conversationId) → Future<SyncResult>
override
toString() → String
A string representation of this object.
inherited
unarchiveConversation(String conversationId) → Future<void>
override
unpinMessage(String conversationId, String messageId) → Future<void>
override
unstarMessage(String messageId) → Future<void>
override
unsubscribePresence(String userId) → Future<void>
override
updateConversation(String conversationId, UpdateConversationParams params) → Future<Conversation>
override
updateParticipantStatus(String conversationId, String userId, ParticipantStatus status) → Future<void>
override
uploadFile(UploadFileParams params) → Stream<FileUploadProgress>
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited