ChatController class
Bridge this controller to REST, WebSocket, Firebase, Stream, or your own SDK.
- Inheritance
-
- Object
- ChangeNotifier
- ChatController
Constructors
-
ChatController({required ChatUser currentUser, ChatSettings settings = const ChatSettings(), List<
ChatConversation> conversations = const [], ChatCapabilities capabilities = const ChatCapabilities()}) -
Creates a controller for
currentUserand the supplied conversation snapshot.
Properties
- capabilities → ChatCapabilities
-
Controls optional reply and reaction UI.
final
-
conversations
→ List<
ChatConversation> -
Read-only list of loaded conversations.
no setter
- currentUser → ChatUser
-
Signed-in user used to identify locally authored messages.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Whether any listeners are currently registered.
no setterinherited
-
onAttach
↔ FutureOr<
void> Function(String conversationId, List<ChatAttachment> attachments)? -
Invoked when the host app handles selected attachment references.
getter/setter pair
-
onCreatePoll
↔ FutureOr<
void> Function(String conversationId, ChatPoll poll)? -
Invoked when the user creates a poll.
getter/setter pair
-
onDeleteMessage
↔ FutureOr<
void> Function(String conversationId, String messageId)? -
Invoked before a locally loaded message is removed.
getter/setter pair
-
onEditMessage
↔ FutureOr<
void> Function(String conversationId, String messageId, String text)? -
Invoked before a local message is updated with edited text.
getter/setter pair
-
onForwardMessage
↔ FutureOr<
void> Function(String conversationId, String messageId, List<String> destinations)? -
Invoked when a message should be forwarded to destination conversations.
getter/setter pair
-
onMarkRead
↔ FutureOr<
void> Function(String conversationId, String messageId)? -
Invoked when the user marks a message as read.
getter/setter pair
-
onPinMessage
↔ FutureOr<
void> Function(String conversationId, String messageId, bool pinned)? -
Invoked when the pin state of a message changes.
getter/setter pair
-
onReact
↔ FutureOr<
void> Function(String conversationId, String messageId, String text)? -
Invoked when the user selects an emoji reaction.
getter/setter pair
-
onReportMessage
↔ FutureOr<
void> Function(String conversationId, String messageId)? -
Invoked when the user reports a message.
getter/setter pair
-
onSaveMessage
↔ FutureOr<
void> Function(String conversationId, String messageId, bool pinned)? -
Invoked when local saved-message state changes.
getter/setter pair
-
onScheduleMessage
↔ FutureOr<
void> Function(String conversationId, ChatMessage message, DateTime sendAt)? -
Invoked when the user schedules a message for later delivery.
getter/setter pair
-
onSendMessage
↔ FutureOr<
void> Function(String conversationId, ChatMessage message)? -
Called before local state is updated. Persist or send this message to your backend here.
getter/setter pair
-
onSettingsChanged
↔ FutureOr<
void> Function(ChatSettings settings)? -
Invoked after the user changes a chat preference.
getter/setter pair
-
onTranslateMessage
↔ FutureOr<
String> Function(String text, String targetLanguage)? -
Invoked when a host service should translate
textto a target language.getter/setter pair -
onTypingChanged
↔ FutureOr<
void> Function(String conversationId, TypingState state)? -
Invoked when a host app sends typing-state changes.
getter/setter pair
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
- settings → ChatSettings
-
Current chat preferences.
no setter
Methods
-
addListener(
VoidCallback listener) → void -
Register a closure to be called when the object changes.
inherited
-
attach(
String conversationId, List< ChatAttachment> files) → Future<void> - Delegates attachment handling to onAttach.
-
byId(
String id) → ChatConversation? - Returns a loaded conversation by ID, or null when unavailable.
-
createPoll(
String conversationId, ChatPoll poll) → Future< void> - Delegates poll creation to onCreatePoll.
-
deleteMessage(
String conversationId, String messageId) → Future< void> - Removes a message locally after the host delete callback succeeds.
-
dispose(
) → void -
Discards any resources used by the object.
inherited
-
draftFor(
String conversationId) → ChatDraft? - Returns a locally saved draft, if any.
-
editMessage(
String conversationId, String messageId, String text) → Future< void> - Updates a message locally after the host edit callback succeeds.
-
forwardMessage(
String conversationId, String messageId, List< String> destinations) → Future<void> - Delegates forwarding to onForwardMessage.
-
isMessageSaved(
String messageId) → bool - Whether a message is locally marked as saved.
-
markRead(
String conversationId, String messageId) → Future< void> - Delegates read state to onMarkRead.
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
notifyListeners(
) → void -
Call all the registered listeners.
inherited
-
pinMessage(
String conversationId, String messageId) → Future< void> - Toggles a message pin after delegating persistence to onPinMessage.
-
react(
String conversationId, String messageId, String emoji) → void - Delegates an emoji reaction to onReact.
-
removeListener(
VoidCallback listener) → void -
Remove a previously registered closure from the list of closures that are
notified when the object changes.
inherited
-
replaceConversations(
List< ChatConversation> conversations) → void - Replaces loaded conversations with a fresh backend snapshot.
-
reportMessage(
String conversationId, String messageId) → Future< void> - Delegates message reporting to onReportMessage.
-
saveDraft(
String conversationId, String text) → void -
Saves draft text locally, or removes the draft when
textis blank. -
scheduleText(
String conversationId, String text, DateTime sendAt, {ChatMessage? replyTo}) → Future< void> - Creates a scheduled text message through the host callback.
-
searchMessages(
String conversationId, String query) → List< ChatMessage> - Searches loaded message text and attachment names in one conversation.
-
sendText(
String conversationId, String text, {ChatMessage? replyTo}) → Future< void> -
Optimistically sends non-empty
textand delegates transport to onSendMessage. -
setTyping(
String conversationId, TypingState state) → void - Delegates a typing state change to onTypingChanged.
-
toggleSavedMessage(
String conversationId, String messageId) → Future< void> - Toggles local saved state and delegates persistence to onSaveMessage.
-
toString(
) → String -
A string representation of this object.
inherited
-
translateMessage(
String text, String targetLanguage) → Future< String?> - Delegates text translation to onTranslateMessage.
-
updateSettings(
ChatSettings settings) → void - Updates preferences and notifies listeners before host persistence completes.
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited