rivium_chat library
RiviumChat SDK - Headless chat-as-a-service for Flutter.
This is a minimal, unopinionated SDK that works with any state management.
For pre-built UI widgets, use the rivium_chat_ui package.
Quick Start
import 'package:rivium_chat/rivium_chat.dart';
// Configure
final config = RiviumChatConfig(
apiKey: 'your-api-key',
userId: 'user-123',
);
// Create client
final client = RiviumChatClient(config);
// Connect
await client.connect();
// Subscribe to a room
await client.subscribeRoom('room-id');
// Listen to messages
client.onMessage.listen((message) {
print('New message: ${message.content}');
});
// Send a message
await client.sendMessage('room-id', content: 'Hello!');
// Cleanup
client.dispose();
Classes
- Attachment
- Represents a file attachment in a message.
- AuthErrorEvent
- The server refused the user's identity and a token refresh cannot fix it: the token was revoked or invalid, the project requires a token, or your RiviumChatConfig.tokenProvider failed. Typically: send the user to login.
- ConnectionErrorEvent
- Event emitted when a connection error occurs.
- FileUploadResult
- Result of a file upload operation.
- Message
- Represents a chat message.
- MessageDeletion
- Event emitted when a message is deleted.
- MessageEditEvent
- Event emitted when a message is edited.
- MessagePinEvent
- Event emitted when a message is pinned or unpinned.
- PaginatedMessages
- Paginated response for message queries.
- Participant
- Represents a participant in a chat room.
- PresenceEvent
- Event emitted when user presence changes.
- Reaction
- Represents an emoji reaction on a message.
- ReactionEvent
- Event emitted when a reaction is added or removed.
- ReadReceipt
- Event emitted when a user reads messages in a room.
- RealtimeParseError
- Emitted when a realtime frame arrives but the SDK can't parse or dispatch it. Historically these were swallowed silently, which made intermittent "missing message" bugs impossible to diagnose. Wire this to your observability layer (RiviumTrace, Sentry, etc.) so a bad wire payload surfaces instead of vanishing.
- RiviumChatClient
- Main client for the RiviumChat SDK.
- RiviumChatConfig
- Configuration for the RiviumChat SDK.
- Room
- Represents a chat room (conversation).
- RoomUnread
- Unread count for a specific room.
- SubscriptionStateEvent
- Event emitted when subscription state changes.
- TypingEvent
- Event emitted when a user is typing.
- UnreadSummary
- Summary of unread messages across all rooms.
Enums
- ConnectionState
- Connection states for the realtime service.
- MessageType
- Message content types supported by RiviumChat.
- ParticipantRole
- Participant roles within a room.
- RoomType
- Room types for conversations.
- SubscriptionStatus
- Subscription states for room channels.
Typedefs
-
ChatTokenProvider
= Future<
String> Function() - Returns a user token for the current user, issued by your server.
-
FileUploader
= Future<
FileUploadResult> Function(File file) - Callback type for uploading files.