ChatDatabase class abstract
Interface for chat database operations.
Implementations can use SQLite, Drift, or custom databases.
- Implemented types
Constructors
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
addReaction(
String messageId, Reaction reaction) → Future< void> - Adds a reaction to a message.
-
clearSyncState(
) → Future< void> - Clears the sync state (called on logout).
-
close(
) → Future< void> - Closes the database connection.
-
deleteCompletedOperations(
) → Future< void> -
Deletes all completed operations.
inherited
-
deleteConversation(
String conversationId) → Future< void> - Deletes a conversation.
-
deleteMessages(
String conversationId) → Future< void> - Deletes messages for a conversation.
-
deleteOperation(
String operationId) → Future< void> -
Deletes an outbound operation.
inherited
-
deleteParticipants(
String conversationId) → Future< void> - Deletes all participants for a conversation.
-
deletePinnedEvents(
String conversationId) → Future< void> - Deletes all pinned events for a conversation.
-
deletePinnedEventsForMessage(
String messageId) → Future< void> - Deletes pinned events for a specific message.
-
getAllConversations(
{ConversationFilter? filter}) → Future< List< Conversation> > - Gets all conversations (one-shot, not a stream).
-
getConversation(
String conversationId) → Future< Conversation?> - Gets a conversation by ID.
-
getMessage(
String messageId) → Future< Message?> - Gets a message by ID.
-
getMessagesByConversation(
String conversationId, {int limit = 50}) → Future< List< Message> > - Gets messages for a conversation (one-shot, not a stream).
-
getParticipantsForConversation(
String conversationId) → Future< List< Participant> > - Gets participants for a conversation.
-
getPendingOperations(
) → Future< List< OutboundOperation> > -
Gets all pending outbound operations.
inherited
-
getPinnedEvents(
String conversationId) → Future< List< PinnedEvent> > - Gets all pinned events for a conversation (one-shot, not a stream).
-
getReactionsForMessage(
String messageId) → Future< List< Reaction> > - Gets reactions for a message.
-
getSyncState(
) → Future< SyncState?> - Gets the current sync state.
-
initialize(
) → Future< void> - Initializes the database.
-
insertConversation(
Conversation conversation) → Future< void> - Inserts a conversation.
-
insertMessage(
Message message) → Future< String> -
Inserts a message (with deduplication).
Returns the actual primary key of the row — either the existing local
message's PK (if dedup matched) or
message.idfor new inserts. -
insertOperation(
OutboundOperation operation) → Future< void> -
Inserts an outbound operation.
inherited
-
insertPinnedEvent(
PinnedEvent event) → Future< void> - Inserts a pinned event.
-
markConversationMessagesAsDelivered(
String conversationId, {String? senderIdFilter}) → Future< void> - Marks sent messages in a conversation as delivered.
-
markConversationMessagesAsRead(
String conversationId, {String? senderIdFilter}) → Future< void> - Marks sent/delivered messages in a conversation as read.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
removeReaction(
String messageId, String reactionId) → Future< void> - Removes a reaction from a message.
-
replacePinnedMessage(
String conversationId, String messageId, {DateTime? pinnedUntil}) → Future< void> -
Replaces the currently pinned message in a conversation with
messageId. -
resetConversationUnreadCount(
String conversationId) → Future< void> - Resets a conversation's unread count to zero.
-
runInTransaction<
T> (Future< T> action()) → Future<T> - Executes the given function within a database transaction.
-
toString(
) → String -
A string representation of this object.
inherited
-
updateConversation(
Conversation conversation) → Future< void> - Updates a conversation.
-
updateConversationLastMessage(
String conversationId, {required String messageId, required DateTime messageAt, bool incrementUnread = true}) → Future< void> - Updates the last message info for a conversation and optionally increments the unread count.
-
updateMessage(
String messageId, {String? serverId, String? content, MessageStatus? status, DateTime? serverTimestamp, bool? isDeleted, bool? isEdited, bool? isStarred, bool? isPinned, DateTime? pinnedUntil}) → Future< void> - Updates a message.
-
updateOperation(
OutboundOperation operation) → Future< void> -
Updates an outbound operation.
inherited
-
updatePinnedEvent(
String eventId, {DateTime? unpinnedAt}) → Future< void> - Updates a pinned event (typically to set unpinnedAt).
-
updateSyncState(
SyncState state) → Future< void> - Updates the sync state.
-
upsertParticipants(
String conversationId, List< Participant> participants) → Future<void> - Replaces all participants for a conversation.
-
watchConversations(
{ConversationFilter? filter}) → Stream< List< Conversation> > - Watches all conversations.
-
watchMessages(
String conversationId) → Stream< List< Message> > - Watches messages for a conversation.
-
watchPinnedEvents(
String conversationId) → Stream< List< PinnedEvent> > - Watches active pinned events for a conversation.
-
watchPinnedMessages(
String conversationId) → Stream< List< Message> > - Watches pinned messages for a conversation.
-
watchStarredMessages(
) → Stream< List< Message> > - Watches starred messages.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited