Dart (Flutter) API
Generated from the source and its doc comments (sdk/client-flutter/lib/agentim_client.dart).
dart pub add agentim_clientClientOptions
Section titled “ClientOptions”class ClientOptionsHow the client starts: the server address, this device’s id, the cache, the token provider and how it names itself.
TokenRefused
Section titled “TokenRefused”class TokenRefused implements ExceptionThrown by a token provider when the backend refuses the user.
AgentIMError
Section titled “AgentIMError”class AgentIMError implements ExceptionThe server’s code (forbidden, not_found, conflict, bad_request, blocked, rate_limited…) or the client’s (disconnected, timeout, closed…); unknown codes pass through as they are.
AgentIMError.toString
Section titled “AgentIMError.toString”String toString()code: message.
Observed
Section titled “Observed”class Observed<T>A value the UI follows: [value] stays the same object until it changes.
Observed.value
Section titled “Observed.value”T get valueThe current value.
Observed.watch
Section titled “Observed.watch”Stream<T> watch() async*The current value, then every change.
Connection
Section titled “Connection”class ConnectionThe connection state and why: state is closed, connecting, connected, disconnected, suspended or failed.
Messages
Section titled “Messages”class MessagesOne conversation’s messages as shown, oldest first; each has key, content, status (sent, sending, failed), state, sender_type…
Messages.olderEnd
Section titled “Messages.olderEnd”String? olderEnd;Why nothing older can be loaded: start (the beginning) or retention (deleted by the retention period).
Messages.debugApplyEvent
Section titled “Messages.debugApplyEvent”void debugApplyEvent(Map<String, dynamic> e)Applies a messages event as the client does, for tests.
Messages.loadOlder
Section titled “Messages.loadOlder”Future<bool> loadOlder()The page before the oldest shown: the cache first, then the server. False at the start.
Messages.jumpTo
Section titled “Messages.jumpTo”Future<void> jumpTo(int seq)A page around a message (it stays loaded).
AgentIMClient
Section titled “AgentIMClient”class AgentIMClientThe AgentIM client for one account on one device: keeps the connection, syncs, sends the offline queue in order, keeps the local cache, and turns everything into observable state.
AgentIMClient.version
Section titled “AgentIMClient.version”static String version()The version of the native core.
AgentIMClient.create
Section titled “AgentIMClient.create”static AgentIMClient create(ClientOptions o)Starts a client with its options: the server address, this device’s id, the token provider and the cache. Nothing connects until connect.
AgentIMClient.command
Section titled “AgentIMClient.command”Future<Object?> command(Map<String, Object?> cmd)Any core command ({'cmd': …}); completes with its result.
AgentIMClient.setNetwork
Section titled “AgentIMClient.setNetwork”void setNetwork(bool online)The platform’s network: call on every change (connectivity_plus).
AgentIMClient.setForeground
Section titled “AgentIMClient.setForeground”void setForeground(bool foreground)The app came to the foreground or went to the background (AppLifecycleListener).
AgentIMClient.messages
Section titled “AgentIMClient.messages”Messages messages(String convId)The conversation’s messages, kept up to date.
AgentIMClient.connect
Section titled “AgentIMClient.connect”Future<void> connect()Connects and keeps connecting: reconnects with backoff when the network or the server goes, syncs what it missed, sends the offline queue.
AgentIMClient.disconnect
Section titled “AgentIMClient.disconnect”Future<void> disconnect()Closes the connection (the client stays usable; [dispose] frees it).
AgentIMClient.logout
Section titled “AgentIMClient.logout”Future<void> logout()Logs out here: closes and wipes the cache and the queue (GDPR).
AgentIMClient.sendFile
Section titled “AgentIMClient.sendFile”Future<Map<String, dynamic>> sendFile(Returns {client_msg_id, key} once the message is queued and shown. Sends a file or a photo from a path: shown at once as uploading, sent when it is up. A photo loses its EXIF and GPS (unless [keepMetadata]) and gets a 320-pixel thumbnail (docs/en/design/messaging.md).
AgentIMClient.fileUrl
Section titled “AgentIMClient.fileUrl”Future<Map<String, dynamic>> fileUrl(String convId, String fileId, {String variant = 'original'}) asyncA link (valid a few minutes) to read a file: original or thumb.
AgentIMClient.send
Section titled “AgentIMClient.send”Future<Map<String, dynamic>> send(String convId, String text, {String? clientMsgId, String? replyTo, String? threadId, bool alsoInConv = false}) asyncSends a text, optionally as a reply: shown at once as sending, sent when the connection allows, in order. Returns the client_msg_id and the local key; a retry with the same client_msg_id is the same message.
AgentIMClient.edit
Section titled “AgentIMClient.edit”Future<void> edit(String convId, String msgId, String text)Edits one of my messages (by msgId, or by clientMsgId while it is still queued); the change shows at once.
AgentIMClient.recall
Section titled “AgentIMClient.recall”Future<void> recall(String convId, String msgId)Recalls one of my messages for everyone; a message still in the queue is simply not sent.
AgentIMClient.read
Section titled “AgentIMClient.read”Future<void> read(String convId, {int? seq})Marks the conversation read up to seq (default: the newest) on all my devices.
AgentIMClient.retry
Section titled “AgentIMClient.retry”Future<void> retry(String convId, String clientMsgId)Sends a failed message again (the same client_msg_id, so it is never doubled).
AgentIMClient.discard
Section titled “AgentIMClient.discard”Future<void> discard(String convId, String clientMsgId)Drops a failed or waiting message from the queue.
AgentIMClient.react
Section titled “AgentIMClient.react”Future<Object?> react(String convId, String msgId, String key)Adds a reaction (one emoji, or one of the app’s :names:); adding it twice changes nothing.
AgentIMClient.unreact
Section titled “AgentIMClient.unreact”Future<Object?> unreact(String convId, String msgId, String key)Removes my reaction; removing one that is not there changes nothing.
AgentIMClient.pin
Section titled “AgentIMClient.pin”Future<Object?> pin(String convId, String msgId)Pins a message to the conversation; pinning it again changes nothing.
AgentIMClient.unpin
Section titled “AgentIMClient.unpin”Future<Object?> unpin(String convId, String msgId)Unpins a message.
AgentIMClient.listPins
Section titled “AgentIMClient.listPins”Future<Object?> listPins(String convId)The conversation’s pinned messages, latest pin first.
AgentIMClient.pullThread
Section titled “AgentIMClient.pullThread”Future<Object?> pullThread(String convId, String threadId, {int afterSeq = 0})A thread’s root and its replies after afterSeq.
AgentIMClient.listThreads
Section titled “AgentIMClient.listThreads”Future<Object?> listThreads({String? convId})The threads I follow (in one conversation, or all), latest reply first, with unread counts.
AgentIMClient.readThread
Section titled “AgentIMClient.readThread”Future<Object?> readThread(String convId, String threadId, int seq)Marks a thread read up to seq on all my devices.
AgentIMClient.followThread
Section titled “AgentIMClient.followThread”Future<Object?> followThread(String convId, String threadId, {bool follow = true})Follows a thread (its replies notify me) or stops following it.
AgentIMClient.msgSummary
Section titled “AgentIMClient.msgSummary”Future<Object?> msgSummary(String convId, List<String> msgIds)The thread summary, reactions and pin of up to 100 messages (for messages loaded from history).
AgentIMClient.call
Section titled “AgentIMClient.call”Future<Object?> call(String op, [Map<String, Object?> args = const {}])A request that needs the server now (approvals, decisions, queries).
AgentIMClient.debugState
Section titled “AgentIMClient.debugState”Future<Object?> debugState()Everything that helps report a problem: the connection, positions, the queue and recent failures.
AgentIMClient.dispose
Section titled “AgentIMClient.dispose”void dispose()Stops the client; no event is handled after it returns. Waiting calls fail with closed.