ChatProvider class

Provider for managing chat state and UI interactions.

This class manages the state of messages for a specific chat. It handles loading, sending, replying, and deleting messages, and notifies listeners when the state changes.

Example:

final provider = ChatProvider(
  controller: chatController,
  chatId: 'chat-123',
  config: chatConfig,
);
Mixed-in types

Constructors

ChatProvider({required ChatController controller, required String chatId, required ChatConfig config})
Creates a new ChatProvider.

Properties

blockedUsers → Set<String>
Set of blocked user IDs.
no setter
chatId → String
The ID of the chat this provider manages messages for.
final
config → ChatConfig
Configuration for the chat module.
final
controller → ChatController
The controller for chat operations.
final
error → String?
Current error message, if any.
no setter
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Whether any listeners are currently registered.
no setterinherited
hasMore → bool
Whether there are more messages to load.
no setter
inputController → TextEditingController
Text editing controller for the message input field.
final
isLoading → bool
Whether messages are currently loading.
no setter
messages → List<ChatMessage>
The list of visible messages (filtered by blocked users).
no setter
replyingTo → ChatMessage?
Message currently being replied to, if any.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
unreadCount → int
Number of unread messages.
no setter

Methods

addListener(VoidCallback listener) → void
Register a closure to be called when the object changes.
inherited
blockUser(String userId) → Future<void>
Blocks a user.
deleteMessage(ChatMessage message) → Future<void>
Deletes a message.
dispose() → void
Discards any resources used by the object.
override
markAsRead() → Future<void>
Marks messages as read.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners() → void
Call all the registered listeners.
inherited
reloadMessages() → void
Reloads messages (used for retry).
removeListener(VoidCallback listener) → void
Remove a previously registered closure from the list of closures that are notified when the object changes.
inherited
sendMessage(CdxChatLocalizations loc, {required void onInputError(String)}) → Future<void>
Sends a message or reply based on the current state.
setReplyTo(ChatMessage? message) → void
Sets the message to reply to.
toString() → String
A string representation of this object.
inherited
unblockUser(String userId) → Future<void>
Unblocks a user.

Operators

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