MockChatClient class
In-memory ChatClient for testing and prototyping without a backend.
Stores rooms, users, and messages locally. Events are emitted synchronously when messages are sent. Use emitEvent to simulate server-side events.
- Implemented types
Constructors
- MockChatClient({required String currentUserId})
Properties
- attachments ↔ MockAttachmentsApi
-
File upload, download, and per-room attachment listing.
latefinaloverride-getter
- auth ↔ MockAuthApi
-
Authentication and server health checks.
latefinaloverride-getter
- connectionState → ChatConnectionState
-
Current connection state.
no setteroverride
- contacts ↔ MockContactsApi
-
Contact list, direct messages, blocking.
latefinaloverride-getter
- currentUserId → String
-
final
-
events
→ Stream<
ChatEvent> -
Stream of real-time events (messages, typing, presence, etc.).
no setteroverride
- hashCode → int
-
The hash code for this object.
no setterinherited
- members ↔ MockMembersApi
-
Room membership: invite, remove, ban, role management.
latefinaloverride-getter
- messages ↔ MockMessagesApi
-
Send, edit, delete messages; receipts, typing, threads, pins, search.
latefinaloverride-getter
- onOfflineMessageSent ← void Function(String roomId, String tempId, ChatMessage message)?
-
Optional callback invoked by clients with an offline queue when a
queued send completes after the connection is restored.
no getteroverride
- presence ↔ MockPresenceApi
-
Online presence status for the current user and contacts.
latefinaloverride-getter
- rooms ↔ MockRoomsApi
-
Room lifecycle: create, list, discover, configure, mute, pin.
latefinaloverride-getter
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
stateChanges
→ Stream<
ChatConnectionState> -
Stream that emits whenever the connection state changes.
no setteroverride
- users ↔ MockUsersApi
-
User search, creation, update, and managed-user operations.
latefinaloverride-getter
Methods
-
addMessage(
String roomId, ChatMessage message) → void -
cancelPendingRequests(
[String reason = 'cancelled']) → void -
Cancels every in-flight REST request.
override
-
connect(
) → Future< void> -
Opens the real-time connection (WebSocket/SSE/polling) honoring
ChatConfig.realtimeMode.
override
-
disconnect(
) → Future< void> -
Closes the real-time connection without clearing state.
override
-
dispose(
) → Future< void> -
Releases all resources. The client must not be used after this call.
override
-
emitEvent(
ChatEvent event) → void -
logout(
) → Future< void> -
Disconnects and clears all local state (rooms, messages, contacts).
override
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyTokenRotated(
) → Future< void> -
Notifies the server (via WebSocket) that the auth token has been rotated.
override
-
refresh(
) → Future< void> -
Force a refresh of the room list and (in
polling/manualmodes) pull new messages for any room that changed.override -
refreshRoom(
String roomId) → Future< void> -
Like refresh but scoped to a single room.
override
-
seedRoom(
ChatRoom room) → void -
Test helper: register a room directly in the mock store so subsequent
client.rooms.get(roomId)calls return a properRoomDetail. -
seedRoomMeta(
String roomId, {int? unread, bool? pinned, bool? muted}) → void -
Test/demo helper: seed chat-list metadata (unread badge, pinned,
muted) that the real backend computes/stores but the mock
ChatRoommodel doesn't carry. Null args leave the current value untouched. -
seedUser(
ChatUser user) → void -
Test helper: register a user directly in the mock store so subsequent
client.users.get(userId)calls return them. Pair with seedRoom when a test exercises the DM-draft hydration path. -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited