chat library
Chat Package
A backend-agnostic chat SDK with offline-first support.
Quick Start
// 1. Create configuration
final config = ChatConfig(
databasePath: 'chat.db',
);
// 2. Create registry with adapter
final registry = ChatRegistry.withAdapter(
config: config,
adapter: YourBackendAdapter(),
identityProvider: YourIdentityProvider(),
);
// 3. Create chat instance
final chat = Chat(registry);
// 4. Initialize
await chat.initialize();
// 5. Use it!
final conversations = chat.watchConversations();
await chat.sendMessage(conversationId: '123', content: 'Hello!');
Classes
- AttachmentTypeStrategy
- Strategy for customizing which file extensions are treated as each media type and for overriding MIME type lookups.
- Chat
- Main entry point for Chat SDK.
- ChatAdapter
- Base interface for chat backend adapters.
- ChatConfig
- Configuration for Chat SDK.
- ChatDatabase
- Interface for chat database operations.
- ChatEvent
- Base class for all chat events.
- ChatEventBus
- Event bus for chat events.
- ChatEventBusImpl
- Implementation of ChatEventBus using StreamController.
- ChatIdentityProvider
- Provides the current chat identity to the Chat SDK.
- ChatProvider
- Provides a Chat instance to the widget tree.
- ChatRegistry
- Registry for Chat dependencies.
- ChatRepository
- Main repository interface for chat operations.
- ConnectionEvent
- Event for connection state change.
- ConnectionStateBuilder
- Builder widget that watches connection state.
- Conversation
- A chat conversation (direct message or group).
- ConversationFilter
- Filter for querying conversations.
- ConversationsBuilder
- Builder widget that watches conversations from the Chat SDK.
- ConversationUpdateEvent
- Event for conversation update.
- CreateConversationParams
- Parameters for creating a conversation.
- DatabaseEncryptionConfig
- Configuration for database encryption.
- DefaultAttachmentTypeStrategy
- Default extension sets used by MediaTypeResolver.
- EncryptionService
- Encryption service for chat messages.
- FileAttachment
- File attachment in a message.
- FileUploadProgress
- Progress of file upload.
- HttpChatAdapter
- Base class for HTTP-only adapters.
- JoinConversationParams
- Parameters for joining a conversation.
- LoadMessagesResult
- Result of loading paginated messages.
- MediaTypeResolver
- Single source of truth for MIME type mapping, extension normalization, media type detection, and MessageType inference from attachments.
- Message
- A chat message.
- MessageContent
- Content of a message, supporting both plain and encrypted forms.
- MessageEvent
- Event for new or updated message.
- MessagesBuilder
- Builder widget that watches messages for a specific room.
- OutboundOperation
- An outbound operation to be sent to the server.
- OutboundQueue
- Interface for outbound queue operations.
- OutboundQueueDatabase
- Interface for database operations needed by the queue.
- OutboundQueueImpl
- Implementation of OutboundQueue with database persistence.
- Participant
- Participant in a chat room.
- PendingAttachment
- Pending file attachment for upload.
- PinEvent
- Event for pin/unpin message.
- PinnedEvent
- A pinned message event that tracks when a message was pinned/unpinned.
- PresenceEvent
- Event for user presence (online/offline).
- PresenceResult
- Result of a presence query for a specific user.
- QueueRetryConfig
- Configuration for queue retry behavior.
- Reaction
- Emoji reaction on a message.
- ReactionEvent
- Event for reaction on message.
- ReceiptEvent
- Event for message receipt (delivered/read).
- SendMessageParams
- Parameters for sending a message.
- SocketChatAdapter
- Base class for WebSocket-only adapters.
- SyncEngine
- Interface for sync engine operations.
- SyncEngineImpl
- Implementation of SyncEngine.
- SyncResult
- Result of a sync operation.
- SyncState
- State of synchronization.
- TypingEvent
- Event for typing indicator.
- UpdateConversationParams
- Parameters for updating a conversation.
- UploadFileParams
- Parameters for file upload.
Enums
- ChatConnectionState
- Connection state to the chat backend.
- ChatSessionState
- Current user-scoped readiness of the chat SDK.
- ConversationMode
- Mode of a conversation.
- ConversationStatus
- Status of a conversation.
- ConversationType
- Type of conversation.
- ConversationUpdateType
- Type of conversation update.
- FileUploadStatus
- Status of file upload.
- MessageStatus
- Message delivery status.
- MessageType
- Type of message content.
- OutboundOperationStatus
- Status of an outbound operation.
- OutboundOperationType
- Pending operations in the outbound queue.
- ParticipantRole
- Role of a participant in a room.
- ParticipantStatus
- Status of a participant's membership.
- ReceiptType
- Type of receipt.
- SyncStatus
- Status of synchronization.
Extensions
- ChatBuildContextExtension on BuildContext
- Extension methods on BuildContext for Chat access.
- ConversationExtensions on Conversation
- Extension methods on Conversation.
- MessageExtensions on Message
- Extension methods on Message.
Constants
- kDefaultMaxQueueSize → const int
- Maximum number of operations allowed in queue.
Exceptions / Errors
- ChatAdapterException
- Exception thrown when adapter operations fail.
- ChatDatabaseException
- Exception thrown when database operations fail.
- ChatEncryptionException
- Exception thrown when encryption/decryption fails.
- ChatException
- Base exception for all chat-related errors.
- ChatNotInitializedException
- Exception thrown when chat is not initialized.
- ChatOperationException
- Exception thrown when a required operation fails.
- ChatSyncException
- Exception thrown when sync fails.
- ChatValidationException
- Exception thrown when validation fails.
- UserIdNotSetException
- Exception thrown when userId is required but not set.