Client class

Represents a Matrix client to communicate with a Matrix homeserver and is the entry point for this SDK.

Inheritance
Available Extensions

Constructors

Client(String clientName, {FutureOr<DatabaseApi> databaseBuilder(Client)?, FutureOr<DatabaseApi> legacyDatabaseBuilder(Client)?, Set<KeyVerificationMethod>? verificationMethods, Client? httpClient, Set<String>? importantStateEvents, Set<String>? roomPreviewLastEvents, bool pinUnreadRooms = false, bool pinInvitedRooms = true, int sendMessageTimeoutSeconds = 60, bool requestHistoryOnLimitedTimeline = false, Set<String>? supportedLoginTypes, bool mxidLocalPartFallback = true, bool formatLocalpart = true, @Deprecated('Use [nativeImplementations] instead') ComputeCallback? compute, NativeImplementations nativeImplementations = NativeImplementations.dummy, Level? logLevel, Filter? syncFilter, Duration sendTimelineEventTimeout = const Duration(minutes: 1), Future<MatrixImageFileResizedResponse?> customImageResizer(MatrixImageFileResizeArguments)?, bool shareKeysWithUnverifiedDevices = true, bool enableDehydratedDevices = false, bool receiptsPublicByDefault = true, Future<void> onSoftLogout(Client client)?})
Create a client clientName = unique identifier of this client databaseBuilder: A function that creates the database instance, that will be used. legacyDatabaseBuilder: Use this for your old database implementation to perform an automatic migration databaseDestroyer: A function that can be used to destroy a database instance, for example by deleting files from disk. verificationMethods: A set of all the verification methods this client can handle. Includes: KeyVerificationMethod.numbers: Compare numbers. Most basic, should be supported KeyVerificationMethod.emoji: Compare emojis importantStateEvents: A set of all the important state events to load when the client connects. To speed up performance only a set of state events is loaded on startup, those that are needed to display a room list. All the remaining state events are automatically post-loaded when opening the timeline of a room or manually by calling room.postLoad(). This set will always include the following state events: - m.room.name - m.room.avatar - m.room.message - m.room.encrypted - m.room.encryption - m.room.canonical_alias - m.room.tombstone - some m.room.member events, where needed roomPreviewLastEvents: The event types that should be used to calculate the last event in a room for the room list. Set requestHistoryOnLimitedTimeline to controll the automatic behaviour if the client receives a limited timeline flag for a room. If mxidLocalPartFallback is true, then the local part of the mxid will be shown if there is no other displayname available. If not then this will return "Unknown user". If formatLocalpart is true, then the localpart of an mxid will be formatted in the way, that all "_" characters are becomming white spaces and the first character of each word becomes uppercase. If your client supports more login types like login with token or SSO, then add this to supportedLoginTypes. Set a custom syncFilter if you like. By default the app will use lazy_load_members. Set nativeImplementations to NativeImplementationsIsolate in order to enable the SDK to compute some code in background. Set timelineEventTimeout to the preferred time the Client should retry sending events on connection problems or to Duration.zero to disable it. Set customImageResizer to your own implementation for a more advanced and faster image resizing experience. Set enableDehydratedDevices to enable experimental support for enabling MSC3814 dehydrated devices.

Properties

accessToken String?
This is the access token for the matrix client. When it is undefined, then the user needs to sign in first.
getter/setter pairinherited
accessTokenExpiresAt DateTime?
getter/setter pair
accountData Map<String, BasicEvent>
no setter
accountDataLoading Future?
no setter
allPushNotificationsMuted bool
Whether all push notifications are muted using the .m.rule.master rule of the push rules: https://matrix.org/docs/spec/client_server/r0.6.0#m-rule-master
no setter
archive Future<List<Room>>
no setter
archivedRooms List<ArchivedRoom>
Get a list of the archived rooms
no setter
backgroundSync bool
Controls the background sync (automatically looping forever if turned on). If you use soft logout, you need to manually call ensureNotSoftLoggedOut() before doing any API request after setting the background sync to false, as the soft logout is handeld automatically in the sync loop.
no getter
baseUri Uri?
getter/setter pairinherited
bearerToken String?
getter/setter pairinherited
clientName String
The required name for this client.
final
commands Map<String, FutureOr<String?> Function(CommandArgs)>
final
compute → ComputeCallback?
final
customImageResizer ↔ (Future<MatrixImageFileResizedResponse?> Function(MatrixImageFileResizeArguments)?)
getter/setter pair
database DatabaseApi?
no setter
databaseBuilder → (FutureOr<DatabaseApi> Function(Client)?)
final
deviceID String?
The device ID is an unique identifier for this device.
no setter
deviceName String?
The device name is a human readable identifier for this device.
no setter
devicePushRules PushRuleSet?
Returns the device push rules for the logged in user.
no setter
directChats Map<String, dynamic>
no setter
enableDehydratedDevices bool
getter/setter pair
encryption Encryption?
getter/setter pair
encryptionEnabled bool
Whether this client supports end-to-end encryption using olm.
no setter
fileEncryptionEnabled bool
Whether this client is able to encrypt and decrypt files.
no setter
fingerprintKey String
no setter
firstSyncReceived Future?
getter/setter pair
formatLocalpart bool
final
globalPushRules PushRuleSet?
Returns the global push rules for the logged in user.
no setter
groupCallSessionId String?
no setter
hashCode int
The hash code for this object.
no setterinherited
homeserver Uri?
The homeserver this client is communicating with.
getter/setter pairinherited
httpClient ↔ Client
getter/setter pairinherited
id int?
no setter
identityKey String
no setter
ignoredUsers List<String>
A list of mxids of users who are ignored.
no setter
importantStateEvents Set<String>
getter/setter pair
isUnknownSession bool
Whether this session is unknown to others
no setter
lastStaleCallRun DateTime
stores when we last checked for stale calls
getter/setter pair
legacyDatabaseBuilder → (FutureOr<DatabaseApi> Function(Client)?)
final
loginState LoginState
Returns the current login state.
no setter
mxidLocalPartFallback bool
final
nativeImplementations NativeImplementations
final
onAccountData → CachedStreamController<BasicEvent>
Callback will be called on account data updates.
final
onCacheCleared → CachedStreamController<bool>
Called when the local cache is reset
final
onCallEvents → CachedStreamController<List<BasicEventWithSender>>
Tells you about to-device and room call specific events in sync
final
onEncryptionError → CachedStreamController<SdkError>
Encryption errors are coming here.
final
onEvent → CachedStreamController<EventUpdate>
The newEvent signal is the most important signal in this concept. Every time the app receives a new synchronization, this event is called for every signal to update the GUI. For example, for a new message, it is called: onRoomEvent( "m.room.message", "!chat_id:server.com", "timeline", {sender: "@bob:server.com", body: "Hello world"} )
final
onGroupMember → CachedStreamController<Event>
final
onKeyVerificationRequest → CachedStreamController<KeyVerification>
Will be called when another device is requesting verification with this device.
final
onLoginStateChanged → CachedStreamController<LoginState>
Called when the login state e.g. user gets logged out.
final
onPresence → CachedStreamController<Presence>
Callback will be called on presences.
final
onPresenceChanged → CachedStreamController<CachedPresence>
Callback will be called on presence updates.
final
onRoomKeyRequest → CachedStreamController<RoomKeyRequest>
Will be called when another device is requesting session keys for a room.
final
onRoomState → CachedStreamController<Event>
final
onSoftLogout ↔ (Future<void> Function(Client client)?)
getter/setter pair
onSync → CachedStreamController<SyncUpdate>
When a new sync response is coming in, this gives the complete payload.
final
onSyncStatus → CachedStreamController<SyncStatusUpdate>
This gives the current status of the synchronization
final
onToDeviceEvent → CachedStreamController<ToDeviceEvent>
The onToDeviceEvent is called when there comes a new to device event. It is already decrypted if necessary.
final
onUiaRequest → CachedStreamController<UiaRequest>
When the library calls an endpoint that needs UIA the UiaRequest is passed down this screen. The client can open a UIA prompt based on this.
final
ownProfile Future<Profile>
no setter
pinInvitedRooms bool
If true then unread rooms are pinned at the top of the room list.
getter/setter pair
pinUnreadRooms bool
If true then unread rooms are pinned at the top of the room list.
getter/setter pair
presences Map<String, CachedPresence>
Presences of users by a given matrix ID
getter/setter pair
prevBatch String?
This points to the position in the synchronization history.
getter/setter pair
pushruleEvaluator PushruleEvaluator
Evaluate if an event should notify quickly
no setter
receiptsPublicByDefault bool
Whether read receipts are sent as public receipts by default or just as private receipts.
getter/setter pair
requestHistoryOnLimitedTimeline bool
getter/setter pair
roomPreviewLastEvents Set<String>
getter/setter pair
rooms List<Room>
A list of all rooms the user is participating or invited.
getter/setter pair
roomsLoading Future?
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sendMessageTimeoutSeconds int
getter/setter pair
sendTimelineEventTimeout Duration
final
shareKeysWithUnverifiedDevices bool
getter/setter pair
sortRoomsBy RoomSorter
The compare function how the rooms should be sorted internally. By default rooms are sorted by timestamp of the last m.room.message event or the last event if there is no known message.
no setter
supportedLoginTypes Set<String>
getter/setter pair
syncErrorTimeoutSec int
How long should the app wait until it retrys the synchronisation after an error?
getter/setter pair
syncFilter Filter
final
syncFilterId String?
getter/setter pair
syncPending bool
no setter
syncPresence PresenceType?
Presence that is set on sync.
getter/setter pair
unverifiedDevices List<DeviceKeys>
A list of all not verified and not blocked device keys. Clients should display a warning if this list is not empty and suggest the user to verify or block those devices.
no setter
userDeviceKeys Map<String, DeviceKeysList>
A map of known device keys per user.
no setter
userDeviceKeysLoading Future?
getter/setter pair
userID String?
The Matrix ID of the current logged user.
no setter
verificationMethods Set<KeyVerificationMethod>
getter/setter pair

Methods

abortSync() Future<void>
Blackholes any ongoing sync call. Currently ongoing sync processing is still going to be finished, new data is ignored.
add3PID(String clientSecret, String sid, {AuthenticationData? auth}) Future<void>
This API endpoint uses the User-Interactive Authentication API.
inherited
ban(String roomId, String userId, {String? reason}) Future<void>
Ban a user in the room. If the user is currently in the room, also kick them.
inherited
bind3PID(String clientSecret, String idAccessToken, String idServer, String sid) Future<void>
Binds a 3PID to the user's account through the specified identity server.
inherited
changePassword(String newPassword, {String? oldPassword, AuthenticationData? auth, bool? logoutDevices}) Future<void>
Changes the password. You should either set oldPasswort or another authentication flow.
override
checkHomeserver(Uri homeserverUrl, {bool checkWellKnown = true, Set<String>? overrideSupportedVersions}) Future<(DiscoveryInformation?, GetVersionsResponse, List<LoginFlow>)>
Checks the supported versions of the Matrix protocol and the supported login types. Throws an exception if the server is not compatible with the client and sets homeserver to homeserverUrl if it is. Supports the types Uri and String.
checkUsernameAvailability(String username) Future<bool?>
Checks to see if a username is available, and valid, for the server.
inherited
claimKeys(Map<String, Map<String, String>> oneTimeKeys, {int? timeout}) Future<ClaimKeysResponse>
Claims one-time keys for use in pre-key messages.
inherited
clear() Future<void>
Resets all settings and stops the synchronisation.
clearArchivesFromCache() → void
Remove all the archives stored in cache.
clearCache() Future<void>
Clear all local cached messages, room information and outbound group sessions and perform a new clean sync.
createGroupChat({String? groupName, bool? enableEncryption, List<String>? invite, CreateRoomPreset preset = CreateRoomPreset.privateChat, List<StateEvent>? initialState, Visibility? visibility, HistoryVisibility? historyVisibility, bool waitForSync = true, bool groupCall = false, Map<String, dynamic>? powerLevelContentOverride}) Future<String>
Simplified method to create a new group chat. By default it is a private chat. The encryption is enabled if this client supports encryption and the preset is not a public chat.
createRoom({Map<String, Object?>? creationContent, List<StateEvent>? initialState, List<String>? invite, List<Invite3pid>? invite3pid, bool? isDirect, String? name, Map<String, Object?>? powerLevelContentOverride, CreateRoomPreset? preset, String? roomAliasName, String? roomVersion, String? topic, Visibility? visibility}) Future<String>
Create a new room with various configuration options.
inherited
createSpace({String? name, String? topic, Visibility visibility = Visibility.public, String? spaceAliasName, List<String>? invite, List<Invite3pid>? invite3pid, String? roomVersion, bool waitForSync = false}) Future<String>
Creates a new space and returns the Room ID. The parameters are mostly the same like in createRoom(). Be aware that spaces appear in the rooms list. You should check if a room is a space by using the room.isSpace getter and then just use the room as a space with room.toSpace().
deactivateAccount({AuthenticationData? auth, String? idServer}) Future<IdServerUnbindResult>
Deactivate the user's account, removing all ability for the user to login again.
inherited
defineFilter(String userId, Filter filter) Future<String>
Uploads a new filter definition to the homeserver. Returns a filter ID that may be used in future requests to restrict which events are returned to the client.
inherited
delete3pidFromAccount(String address, ThirdPartyIdentifierMedium medium, {String? idServer}) Future<IdServerUnbindResult>
Removes a third party identifier from the user's account. This might not cause an unbind of the identifier from the identity server.
inherited
deleteDevice(String deviceId, {AuthenticationData? auth}) Future<void>
This API endpoint uses the User-Interactive Authentication API.
inherited
deleteDevices(List<String> devices, {AuthenticationData? auth}) Future<void>
This API endpoint uses the User-Interactive Authentication API.
inherited
deletePusher(PusherId pusher) Future<void>
Variant of postPusher operation that deletes pushers by setting kind: null.
inherited
deletePushRule(String scope, PushRuleKind kind, String ruleId) Future<void>
This endpoint removes the push rule defined in the path.
inherited
deleteRoomAlias(String roomAlias) Future<void>
Remove a mapping of room alias to room ID.
inherited
deleteRoomKeyBySessionId(String roomId, String sessionId, String version) Future<RoomKeysUpdateResponse>
Delete a key from the backup.
inherited
deleteRoomKeys(String version) Future<RoomKeysUpdateResponse>
Delete the keys from the backup.
inherited
deleteRoomKeysByRoomId(String roomId, String version) Future<RoomKeysUpdateResponse>
Delete the keys from the backup for a given room.
inherited
deleteRoomKeysBySessionId(String roomId, String sessionId, String version) Future<RoomKeysUpdateResponse>
inherited
deleteRoomKeysVersion(String version) Future<void>
Delete an existing key backup. Both the information about the backup, as well as all key data related to the backup will be deleted.
inherited
deleteRoomTag(String userId, String roomId, String tag) Future<void>
Remove a tag from the room.
inherited
dispose({bool closeDatabase = true}) Future<void>
Stops the synchronization and closes the database. After this you can safely make this Client instance null.
ensureNotSoftLoggedOut([Duration expiresIn = const Duration(minutes: 1)]) Future<void>
Checks if the token expires in under expiresIn time and calls the given onSoftLogout() if so. You have to provide onSoftLogout in the Client constructor. Otherwise this will do nothing.
exportDump() Future<String?>
dumps the local database and exports it into a String.
fetchCurrentPresence(String userId, {bool fetchOnlyFromCached = false}) Future<CachedPresence>
The newest presence of this user if there is any. Fetches it from the database first and then from the server if necessary or returns offline.
fetchOwnProfile({bool getFromRooms = true, bool cache = true}) Future<Profile>
Returns the user's own displayname and avatar url. In Matrix it is possible that one user can have different displaynames and avatar urls in different rooms. This returns the profile from the first room by default, override getFromRooms to false to fetch from homeserver.
fetchOwnProfileFromServer({bool useServerCache = false}) Future<Profile>
Returns the user's own displayname and avatar url. In Matrix it is possible that one user can have different displaynames and avatar urls in different rooms. Tries to get the profile from homeserver first, if failed, falls back to a profile from a room where the user exists. Set useServerCache to true to get any prior value from this function
forgetRoom(String roomId) Future<void>
This API stops a user remembering about a particular room.
inherited
generateUniqueTransactionId() String
getAccount3PIDs() Future<List<ThirdPartyIdentifier>?>
Gets a list of the third party identifiers that the homeserver has associated with the user's account.
inherited
getAccountData(String userId, String type) Future<Map<String, Object?>>
Get some account data for the client. This config is only visible to the user that set the account data.
inherited
getAccountDataPerRoom(String userId, String roomId, String type) Future<Map<String, Object?>>
Get some account data for the client on a given room. This config is only visible to the user that set the account data.
inherited
getArchiveRoomFromCache(String roomId) ArchivedRoom?
Return an archive room containing the room and the timeline for a specific archived room.
getAvatarUrl(String userId) Future<Uri?>
Get the user's avatar URL. This API may be used to fetch the user's own avatar URL or to query the URL of other users; either locally or on remote homeservers.
inherited
getCapabilities() Future<Capabilities>
Gets information about the server's supported feature set and other relevant capabilities.
inherited
getConfig() Future<ServerConfig>
Gets the config of the content repository, such as upload limit.
override
getContent(String serverName, String mediaId, {bool? allowRemote}) Future<FileResponse>
serverName The server name from the mxc:// URI (the authoritory component)
inherited
getContentOverrideName(String serverName, String mediaId, String fileName, {bool? allowRemote}) Future<FileResponse>
This will download content from the content repository (same as the previous endpoint) but replace the target file name with the one provided by the caller.
inherited
getContentThumbnail(String serverName, String mediaId, int width, int height, {Method? method, bool? allowRemote}) Future<FileResponse>
Download a thumbnail of content from the content repository. See the Thumbnails section for more information.
inherited
getDevice(String deviceId) Future<Device>
Gets information on a single device, by device id.
inherited
getDevices() Future<List<Device>?>
Gets information about all devices for the current user.
inherited
getDirectChatFromUserId(String userId) String?
Returns the (first) room ID from the store which is a private chat with the user userId. Returns null if there is none.
getDiscoveryInformationsByUserId(String MatrixIdOrDomain) Future<DiscoveryInformation>
Gets discovery information about the domain. The file may include additional keys.
getDisplayName(String userId) Future<String?>
Get the user's display name. This API may be used to fetch the user's own displayname or to query the name of other users; either locally or on remote homeservers.
inherited
getEventByPushNotification(PushNotification notification, {bool storeInDatabase = true, Duration timeoutForServerRequests = const Duration(seconds: 8), bool returnNullIfSeen = true}) Future<Event?>
Fetches the corresponding Event object from a notification including a full Room object with the sender User object in it. Returns null if this push notification is not corresponding to an existing event. The client does not need to be initialized first. If it is not initialized, it will only fetch the necessary parts of the database. This should make it possible to run this parallel to another client with the same client name. This also checks if the given event has a readmarker and returns null in this case.
getEventByTimestamp(String roomId, int ts, Direction dir) Future<GetEventByTimestampResponse>
Get the ID of the event closest to the given timestamp, in the direction specified by the dir parameter.
inherited
getEventContext(String roomId, String eventId, {int? limit, String? filter}) Future<EventContext>
This API returns a number of events that happened just before and after the specified event. This allows clients to get the context surrounding an event.
inherited
getEvents({String? from, int? timeout}) Future<GetEventsResponse>
This will listen for new events and return them to the caller. This will block until an event is received, or until the timeout is reached.
inherited
getFilter(String userId, String filterId) Future<Filter>
userId The user ID to download a filter for.
inherited
getJoinedMembersByRoom(String roomId) Future<Map<String, RoomMember>?>
This API returns a map of MXIDs to member info objects for members of the room. The current user must be in the room for it to work, unless it is an Application Service in which case any of the AS's users must be in the room. This API is primarily for Application Services and should be faster to respond than /members as it can be implemented more efficiently on the server.
inherited
getJoinedRooms() Future<List<String>>
This API returns a list of the user's current rooms.
inherited
getKeysChanges(String from, String to) Future<GetKeysChangesResponse>
Gets a list of users who have updated their device identity keys since a previous sync token.
inherited
getLocalAliases(String roomId) Future<List<String>>
Get a list of aliases maintained by the local server for the given room.
inherited
getLoginFlows() Future<List<LoginFlow>?>
Gets the homeserver's supported login types to authenticate users. Clients should pick one of these and supply it as the type when logging in.
inherited
getMembersByRoom(String roomId, {String? at, Membership? membership, Membership? notMembership}) Future<List<MatrixEvent>?>
Get the list of members for this room.
inherited
getNotifications({String? from, int? limit, String? only}) Future<GetNotificationsResponse>
This API is used to paginate through the list of events that the user has been, or would have been notified about.
inherited
getOneEvent(String eventId) Future<MatrixEvent>
Get a single event based on event_id. You must have permission to retrieve this event e.g. by being a member in the room for this event.
inherited
getOneRoomEvent(String roomId, String eventId) Future<MatrixEvent>
Get a single event based on roomId/eventId. You must have permission to retrieve this event e.g. by being a member in the room for this event.
inherited
getPresence(String userId) Future<GetPresenceResponse>
Get the given user's presence state.
inherited
getProfileFromUserId(String userId, {bool cache = true, bool getFromRooms = true}) Future<Profile>
Get the combined profile information for this user. If getFromRooms is true then the profile will first be searched from the room memberships. This is unstable if the given user makes use of different displaynames and avatars per room, which is common for some bots and bridges. If cache is true then the profile get cached for this session. Please note that then the profile may become outdated if the user changes the displayname or avatar in this session.
getProtocolMetadata(String protocol) Future<Protocol>
Fetches the metadata from the homeserver about a particular third party protocol.
inherited
getProtocols() Future<Map<String, Protocol>>
Fetches the overall metadata about protocols supported by the homeserver. Includes both the available protocols and all fields required for queries against each protocol.
inherited
getPublicRooms({int? limit, String? since, String? server}) Future<GetPublicRoomsResponse>
Lists the public rooms on the server.
inherited
getPushers() Future<List<Pusher>?>
Gets all currently active pushers for the authenticated user.
inherited
getPushRule(String scope, PushRuleKind kind, String ruleId) Future<PushRule>
Retrieve a single specified push rule.
inherited
getPushRuleActions(String scope, PushRuleKind kind, String ruleId) Future<List<Object?>>
This endpoint get the actions for the specified push rule.
inherited
getPushRules() Future<PushRuleSet>
Retrieve all push rulesets for this user. Clients can "drill-down" on the rulesets by suffixing a scope to this path e.g. /pushrules/global/. This will return a subset of this data under the specified key e.g. the global key.
inherited
getRelatingEvents(String roomId, String eventId, {String? from, String? to, int? limit, Direction? dir}) Future<GetRelatingEventsResponse>
Retrieve all of the child events for a given parent event.
inherited
getRelatingEventsWithRelType(String roomId, String eventId, String relType, {String? from, String? to, int? limit, Direction? dir}) Future<GetRelatingEventsWithRelTypeResponse>
Retrieve all of the child events for a given parent event which relate to the parent using the given relType.
inherited
getRelatingEventsWithRelTypeAndEventType(String roomId, String eventId, String relType, String eventType, {String? from, String? to, int? limit, Direction? dir}) Future<GetRelatingEventsWithRelTypeAndEventTypeResponse>
Retrieve all of the child events for a given parent event which relate to the parent using the given relType and have the given eventType.
inherited
getRoomByAlias(String alias) Room?
getRoomById(String id) Room?
Searches in the local cache for the given room and returns null if not found. If you have loaded the loadArchive() before, it can also return archived rooms.
getRoomEvents(String roomId, Direction dir, {String? from, String? to, int? limit, String? filter}) Future<GetRoomEventsResponse>
This API returns a list of message and state events for a room. It uses pagination query parameters to paginate history in the room.
inherited
getRoomIdByAlias(String roomAlias) Future<GetRoomIdByAliasResponse>
Requests that the server resolve a room alias to a room ID.
inherited
getRoomKeyBySessionId(String roomId, String sessionId, String version) Future<KeyBackupData>
Retrieve a key from the backup.
inherited
getRoomKeys(String version) Future<RoomKeys>
Retrieve the keys from the backup.
inherited
getRoomKeysByRoomId(String roomId, String version) Future<RoomKeyBackup>
Retrieve the keys from the backup for a given room.
inherited
getRoomKeysBySessionId(String roomId, String sessionId, String version) Future<KeyBackupData>
inherited
getRoomKeysVersion(String version) Future<GetRoomKeysVersionResponse>
Get information about an existing backup.
inherited
getRoomKeysVersionCurrent() Future<GetRoomKeysVersionCurrentResponse>
Get information about the latest backup version.
inherited
getRoomState(String roomId) Future<List<MatrixEvent>>
Get the state events for the current state of a room.
inherited
getRoomStateWithKey(String roomId, String eventType, String stateKey) Future<Map<String, Object?>>
Looks up the contents of a state event in a room. If the user is joined to the room then the state is taken from the current state of the room. If the user has left the room then the state is taken from the state of the room when they left.
inherited
getRoomTags(String userId, String roomId) Future<Map<String, Tag>?>
List the tags set by a user on a room.
inherited
getRoomVisibilityOnDirectory(String roomId) Future<Visibility?>
Gets the visibility of a given room on the server's public room directory.
inherited
getSpaceHierarchy(String roomId, {bool? suggestedOnly, int? limit, int? maxDepth, String? from}) Future<GetSpaceHierarchyResponse>
Paginates over the space tree in a depth-first manner to locate child rooms of a given space.
inherited
getThreadRoots(String roomId, {Include? include, int? limit, String? from}) Future<GetThreadRootsResponse>
Paginates over the thread roots in a room, ordered by the latest_event of each thread root in its bundle.
inherited
getTokenOwner() Future<TokenOwnerInfo>
Gets information about the owner of a given access token.
inherited
getTurnServer() Future<TurnServerCredentials>
This API provides credentials for the client to use when initiating calls.
inherited
getUrlPreview(Uri url, {int? ts}) Future<GetUrlPreviewResponse>
Get information about a URL for the client. Typically this is called when a client sees a URL in a message and wants to render a preview for the user.
inherited
getUserDeviceKeysByCurve25519Key(String senderKey) DeviceKeys?
Gets user device keys by its curve25519 key. Returns null if it isn't found
getUserProfile(String userId) Future<ProfileInformation>
Get the combined profile information for this user. This API may be used to fetch the user's own profile information or other users; either locally or on remote homeservers. This API may return keys which are not limited to displayname or avatar_url.
inherited
getVersions() Future<GetVersionsResponse>
Gets the versions of the specification supported by the server.
inherited
getWellknown() Future<DiscoveryInformation>
Gets discovery information about the domain. The file may include additional keys, which MUST follow the Java package naming convention, e.g. com.example.myapp.property. This ensures property names are suitably namespaced for each application and reduces the risk of clashes.
inherited
getWhoIs(String userId) Future<WhoIsInfo>
Gets information about a particular user.
inherited
handleSync(SyncUpdate sync, {Direction? direction}) Future<void>
Use this method only for testing utilities!
ignoreUser(String userId) Future<void>
Ignore another user. This will clear the local cached messages to hide all previous messages from this user.
importDump(String export) Future<bool>
imports a dumped session
init({String? newToken, DateTime? newTokenExpiresAt, String? newRefreshToken, Uri? newHomeserver, String? newUserID, String? newDeviceName, String? newDeviceID, String? newOlmAccount, bool waitForFirstSync = true, bool waitUntilLoadCompletedLoaded = true, void onMigration()?}) Future<void>
Sets the user credentials and starts the synchronisation.
inviteBy3PID(String roomId, String address, String idAccessToken, String idServer, String medium) Future<void>
Note that there are two forms of this API, which are documented separately. This version of the API does not require that the inviter know the Matrix identifier of the invitee, and instead relies on third party identifiers. The homeserver uses an identity server to perform the mapping from third party identifier to a Matrix identifier. The other is documented in the joining rooms section.
inherited
inviteUser(String roomId, String userId, {String? reason}) Future<void>
Note that there are two forms of this API, which are documented separately. This version of the API requires that the inviter knows the Matrix identifier of the invitee. The other is documented in the third party invites section.
inherited
isLogged() bool
isPushRuleEnabled(String scope, PushRuleKind kind, String ruleId) Future<bool>
This endpoint gets whether the specified push rule is enabled.
inherited
joinRoom(String roomIdOrAlias, {List<String>? serverName, String? reason, ThirdPartySigned? thirdPartySigned}) Future<String>
Note that this API takes either a room ID or alias, unlike /rooms/{roomId}/join.
inherited
joinRoomById(String roomId, {String? reason, ThirdPartySigned? thirdPartySigned}) Future<String>
Note that this API requires a room ID, not alias. /join/{roomIdOrAlias} exists if you have a room alias.
inherited
kick(String roomId, String userId, {String? reason}) Future<void>
Kick a user from the room.
inherited
knockRoom(String roomIdOrAlias, {List<String>? serverName, String? reason}) Future<String>
Note that this API takes either a room ID or alias, unlike other membership APIs.
inherited
leaveRoom(String roomId, {String? reason}) Future<void>
This API stops a user participating in a particular room.
inherited
loadArchive() Future<List<Room>>
Fetch all the archived rooms from the server and return the list of the room. If you want to have the Timelines bundled with it, use loadArchiveWithTimeline instead.
loadArchiveWithTimeline() Future<List<ArchivedRoom>>
Fetch the archived rooms from the server and return them as a list of ArchivedRoom objects containing the Room and the associated Timeline.
login(LoginType type, {AuthenticationIdentifier? identifier, String? password, String? token, String? deviceId, String? initialDeviceDisplayName, bool? refreshToken, String? user, String? medium, String? address}) Future<LoginResponse>
Handles the login and allows the client to call all APIs which require authentication. Returns false if the login was not successful. Throws MatrixException if login was not successful. To just login with the username 'alice' you set identifier to: AuthenticationUserIdentifier(user: 'alice') Maybe you want to set user to the same String to stay compatible with older server versions.
override
logout() Future<void>
Sends a logout command to the homeserver and clears all local data, including all persistent data from the store.
override
logoutAll() Future<void>
Sends a logout command to the homeserver and clears all local data, including all persistent data from the store.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
oneShotSync() Future<void>
Immediately start a sync and wait for completion. If there is an active sync already, wait for the active sync instead.
peekEvents({String? from, int? timeout, String? roomId}) Future<PeekEventsResponse>
This will listen for new events related to a particular room and return them to the caller. This will block until an event is received, or until the timeout is reached.
inherited
post3PIDs(ThreePidCredentials threePidCreds) Future<Uri?>
Adds contact information to the user's account.
inherited
postPusher(Pusher pusher, {bool? append}) Future<void>
This endpoint allows the creation, modification and deletion of pushers for this user ID. The behaviour of this endpoint varies depending on the values in the JSON body.
inherited
postReceipt(String roomId, ReceiptType receiptType, String eventId, {String? threadId}) Future<void>
This API updates the marker for the given receipt type to the event ID specified.
inherited
postRoomKeysVersion(BackupAlgorithm algorithm, Map<String, Object?> authData) Future<String>
Creates a new backup.
inherited
processToDeviceQueue() Future<void>
Processes the to_device queue and tries to send every entry. This function MAY throw an error, which just means the to_device queue wasn't proccessed all the way.
putRoomKeyBySessionId(String roomId, String sessionId, String version, KeyBackupData data) Future<RoomKeysUpdateResponse>
Store a key in the backup.
inherited
putRoomKeys(String version, RoomKeys backupData) Future<RoomKeysUpdateResponse>
Store several keys in the backup.
inherited
putRoomKeysByRoomId(String roomId, String version, RoomKeyBackup backupData) Future<RoomKeysUpdateResponse>
Store several keys in the backup for a given room.
inherited
putRoomKeysBySessionId(String roomId, String sessionId, String version, KeyBackupData data) Future<RoomKeysUpdateResponse>
inherited
putRoomKeysVersion(String version, BackupAlgorithm algorithm, Map<String, Object?> authData) Future<Map<String, Object?>>
Update information about an existing backup. Only auth_data can be modified.
inherited
queryKeys(Map<String, List<String>> deviceKeys, {int? timeout, String? token}) Future<QueryKeysResponse>
Returns the current devices and identity keys for the given users.
inherited
queryLocationByAlias(String alias) Future<List<Location>>
Retrieve an array of third party network locations from a Matrix room alias.
inherited
queryLocationByProtocol(String protocol, {String? searchFields}) Future<List<Location>>
Requesting this endpoint with a valid protocol name results in a list of successful mapping results in a JSON array. Each result contains objects to represent the Matrix room or rooms that represent a portal to this third party network. Each has the Matrix room alias string, an identifier for the particular third party network protocol, and an object containing the network-specific fields that comprise this identifier. It should attempt to canonicalise the identifier as much as reasonably possible given the network type.
inherited
queryPublicRooms({String? server, PublicRoomQueryFilter? filter, bool? includeAllNetworks, int? limit, String? since, String? thirdPartyInstanceId}) Future<QueryPublicRoomsResponse>
Lists the public rooms on the server, with optional filter.
inherited
queryUserByID(String userid) Future<List<ThirdPartyUser>>
Retrieve an array of third party users from a Matrix User ID.
inherited
queryUserByProtocol(String protocol, {String? fields}) Future<List<ThirdPartyUser>>
Retrieve a Matrix User ID linked to a user on the third party service, given a set of user parameters.
inherited
redactEvent(String roomId, String eventId, String txnId, {String? reason}) Future<String?>
Strips all information out of an event which isn't critical to the integrity of the server-side representation of the room.
inherited
refresh(String refreshToken) Future<RefreshResponse>
Refresh an access token. Clients should use the returned access token when making subsequent API calls, and store the returned refresh token (if given) in order to refresh the new access token when necessary.
inherited
refreshAccessToken() Future<void>
Fetches the refreshToken from the database and tries to get a new access token from the server and then stores it correctly. Unlike the pure API call of Client.refresh() this handles the complete soft logout case. Throws an Exception if there is no refresh token available or the client is not logged in.
register({String? username, String? password, String? deviceId, String? initialDeviceDisplayName, bool? inhibitLogin, bool? refreshToken, AuthenticationData? auth, AccountKind? kind}) Future<RegisterResponse>
Checks to see if a username is available, and valid, for the server. Returns the fully-qualified Matrix user ID (MXID) that has been registered. You have to call checkHomeserver first to set a homeserver.
override
registrationTokenValidity(String token) Future<bool>
Queries the server to determine if a given registration token is still valid at the time of request. This is a point-in-time check where the token might still expire by the time it is used.
inherited
reportContent(String roomId, String eventId, {String? reason, int? score}) Future<void>
Reports an event as inappropriate to the server, which may then notify the appropriate people.
inherited
request(RequestType type, String action, {dynamic data = '', String contentType = 'application/json', Map<String, Object?>? query}) Future<Map<String, Object?>>
Used for all Matrix json requests using the c2s API.
inherited
requestOpenIdToken(String userId, Map<String, Object?> body) Future<OpenIdCredentials>
Gets an OpenID token object that the requester may supply to another service to verify their identity in Matrix. The generated token is only valid for exchanging for user information from the federation API for OpenID.
inherited
requestTokenTo3PIDEmail(String clientSecret, String email, int sendAttempt, {String? nextLink, String? idAccessToken, String? idServer}) Future<RequestTokenResponse>
The homeserver must check that the given email address is not already associated with an account on this homeserver. This API should be used to request validation tokens when adding an email address to an account. This API's parameters and response are identical to that of the /register/email/requestToken endpoint. The homeserver should validate the email itself, either by sending a validation email itself or by using a service it has control over.
inherited
requestTokenTo3PIDMSISDN(String clientSecret, String country, String phoneNumber, int sendAttempt, {String? nextLink, String? idAccessToken, String? idServer}) Future<RequestTokenResponse>
The homeserver must check that the given phone number is not already associated with an account on this homeserver. This API should be used to request validation tokens when adding a phone number to an account. This API's parameters and response are identical to that of the /register/msisdn/requestToken endpoint. The homeserver should validate the phone number itself, either by sending a validation message itself or by using a service it has control over.
inherited
requestTokenToRegisterEmail(String clientSecret, String email, int sendAttempt, {String? nextLink, String? idAccessToken, String? idServer}) Future<RequestTokenResponse>
The homeserver must check that the given email address is not already associated with an account on this homeserver. The homeserver should validate the email itself, either by sending a validation email itself or by using a service it has control over.
inherited
requestTokenToRegisterMSISDN(String clientSecret, String country, String phoneNumber, int sendAttempt, {String? nextLink, String? idAccessToken, String? idServer}) Future<RequestTokenResponse>
The homeserver must check that the given phone number is not already associated with an account on this homeserver. The homeserver should validate the phone number itself, either by sending a validation message itself or by using a service it has control over.
inherited
requestTokenToResetPasswordEmail(String clientSecret, String email, int sendAttempt, {String? nextLink, String? idAccessToken, String? idServer}) Future<RequestTokenResponse>
The homeserver must check that the given email address is associated with an account on this homeserver. This API should be used to request validation tokens when authenticating for the /account/password endpoint.
inherited
requestTokenToResetPasswordMSISDN(String clientSecret, String country, String phoneNumber, int sendAttempt, {String? nextLink, String? idAccessToken, String? idServer}) Future<RequestTokenResponse>
The homeserver must check that the given phone number is associated with an account on this homeserver. This API should be used to request validation tokens when authenticating for the /account/password endpoint.
inherited
runInBackground<T, U>(FutureOr<T> function(U arg), U arg) Future<T>
Performs a full text search across different categories.
inherited
searchUserDirectory(String searchTerm, {int? limit}) Future<SearchUserDirectoryResponse>
Performs a search for users. The homeserver may determine which subset of users are searched, however the homeserver MUST at a minimum consider the users the requesting user shares a room with and those who reside in public rooms (known to the homeserver). The search MUST consider local users to the homeserver, and SHOULD query remote users as part of the search.
inherited
sendMessage(String roomId, String eventType, String txnId, Map<String, Object?> body) Future<String>
This endpoint is used to send a message event to a room. Message events allow access to historical events and pagination, making them suited for "once-off" activity in a room.
inherited
sendToDevice(String eventType, String txnId, Map<String, Map<String, Map<String, dynamic>>> messages) Future<void>
Sends a raw to_device event with a eventType, a txnId and a content messages. Before sending, it tries to re-send potentially queued to_device events and adds the current one to the queue, should it fail.
override
sendToDeviceEncrypted(List<DeviceKeys> deviceKeys, String eventType, Map<String, dynamic> message, {String? messageId, bool onlyVerified = false}) Future<void>
Sends an encrypted message of this eventType to these deviceKeys.
sendToDeviceEncryptedChunked(List<DeviceKeys> deviceKeys, String eventType, Map<String, dynamic> message) Future<void>
Sends an encrypted message of this eventType to these deviceKeys. This request happens partly in the background and partly in the foreground. It automatically chunks sending to device keys based on activity.
sendToDevicesOfUserIds(Set<String> users, String eventType, Map<String, dynamic> message, {String? messageId}) Future<void>
Send an (unencrypted) to device message of a specific eventType to all devices of a set of users.
setAccountData(String userId, String type, Map<String, Object?> content) Future<void>
Set some account data for the client. This config is only visible to the user that set the account data. The config will be available to clients through the top-level account_data field in the homeserver response to /sync.
inherited
setAccountDataPerRoom(String userId, String roomId, String type, Map<String, Object?> content) Future<void>
Set some account data for the client on a given room. This config is only visible to the user that set the account data. The config will be delivered to clients in the per-room entries via /sync.
inherited
setAvatar(MatrixFile? file) Future<void>
Uploads a new user avatar for this user. Leave file null to remove the current avatar.
setAvatarUrl(String userId, Uri? avatarUrl) Future<void>
This API sets the given user's avatar URL. You must have permission to set this user's avatar URL, e.g. you need to have their access_token.
inherited
setDisplayName(String userId, String? displayname) Future<void>
This API sets the given user's display name. You must have permission to set this user's display name, e.g. you need to have their access_token.
inherited
setMuteAllPushNotifications(bool muted) Future<void>
setPresence(String userId, PresenceType presence, {String? statusMsg}) Future<void>
This API sets the given user's presence state. When setting the status, the activity time is updated to reflect that activity; the client does not need to specify the last_active_ago field. You cannot set the presence state of another user.
inherited
setPushRule(String scope, PushRuleKind kind, String ruleId, List<Object?> actions, {String? before, String? after, List<PushCondition>? conditions, String? pattern}) Future<void>
This endpoint allows the creation and modification of user defined push rules.
inherited
setPushRuleActions(String scope, PushRuleKind kind, String ruleId, List<Object?> actions) Future<void>
This endpoint allows clients to change the actions of a push rule. This can be used to change the actions of builtin rules.
inherited
setPushRuleEnabled(String scope, PushRuleKind kind, String ruleId, bool enabled) Future<void>
This endpoint allows clients to enable or disable the specified push rule.
inherited
setReadMarker(String roomId, {String? mFullyRead, String? mRead, String? mReadPrivate}) Future<void>
Sets the position of the read marker for a given room, and optionally the read receipt's location.
inherited
setRoomAlias(String roomAlias, String roomId) Future<void>
roomAlias The room alias to set. Its format is defined in the appendices.
inherited
setRoomStateWithKey(String roomId, String eventType, String stateKey, Map<String, Object?> body) Future<String>
State events can be sent using this endpoint. These events will be overwritten if <room id>, <event type> and <state key> all match.
inherited
setRoomTag(String userId, String roomId, String tag, {double? order, Map<String, Object?> additionalProperties = const {}}) Future<void>
Add a tag to the room.
inherited
setRoomVisibilityOnDirectory(String roomId, {Visibility? visibility}) Future<void>
Sets the visibility of a given room in the server's public room directory.
inherited
setTyping(String userId, String roomId, bool typing, {int? timeout}) Future<void>
Sends a typing notification and initiates a megolm session, if needed
override
setUserId(String s) → void
Used for testing only
startDirectChat(String mxid, {bool? enableEncryption, List<StateEvent>? initialState, bool waitForSync = true, Map<String, dynamic>? powerLevelContentOverride, CreateRoomPreset? preset = CreateRoomPreset.trustedPrivateChat}) Future<String>
Returns an existing direct room ID with this user or creates a new one. By default encryption will be enabled if the client supports encryption and the other user has uploaded any encryption keys.
sync({String? filter, String? since, bool? fullState, PresenceType? setPresence, int? timeout}) Future<SyncUpdate>
Synchronise the client's state with the latest state on the server. Clients use this API when they first log in to get an initial snapshot of the state on the server, and then continue to call this API to get incremental deltas to the state, and to receive new messages.
inherited
toString() String
A string representation of this object.
inherited
uiaRequestBackground<T>(Future<T> request(AuthenticationData? auth)) Future<T>
Run any request and react on user interactive authentication flows here.
unban(String roomId, String userId, {String? reason}) Future<void>
Unban a user from the room. This allows them to be invited to the room, and join if they would otherwise be allowed to join according to its join rules.
inherited
unbind3pidFromAccount(String address, ThirdPartyIdentifierMedium medium, {String? idServer}) Future<IdServerUnbindResult>
Removes a user's third party identifier from the provided identity server without removing it from the homeserver.
inherited
unexpectedResponse(BaseResponse response, Uint8List body) → Never
inherited
unignoreUser(String userId) Future<void>
Unignore a user. This will clear the local cached messages and request them again from the server to avoid gaps in the timeline.
updateAppserviceRoomDirectoryVisibility(String networkId, String roomId, Visibility visibility) Future<Map<String, Object?>>
Updates the visibility of a given room on the application service's room directory.
inherited
updateDevice(String deviceId, {String? displayName}) Future<void>
Updates the metadata on the given device.
inherited
updateUserDeviceKeys({Set<String>? additionalUsers}) Future<void>
upgradeRoom(String roomId, String newVersion) Future<String>
Upgrades the given room to a particular room version.
inherited
uploadContent(Uint8List file, {String? filename, String? contentType}) Future<Uri>
Uploads a file and automatically caches it in the database, if it is small enough and returns the mxc url.
override
uploadCrossSigningKeys({AuthenticationData? auth, MatrixCrossSigningKey? masterKey, MatrixCrossSigningKey? selfSigningKey, MatrixCrossSigningKey? userSigningKey}) Future<void>
Publishes cross-signing keys for the user.
inherited
uploadCrossSigningSignatures(Map<String, Map<String, Map<String, Object?>>> signatures) Future<Map<String, Map<String, Map<String, Object?>>>?>
Publishes cross-signing signatures for the user. The request body is a map from user ID to key ID to signed JSON object.
inherited
uploadKeys({MatrixDeviceKeys? deviceKeys, Map<String, Object?>? oneTimeKeys, Map<String, Object?>? fallbackKeys}) Future<Map<String, int>>
Publishes end-to-end encryption keys for the device. https://matrix.org/docs/spec/client_server/r0.6.1#post-matrix-client-r0-keys-query
inherited
userOwnsEncryptionKeys(String userId) Future<bool>
Checks if the given user has encryption keys. May query keys from the server to answer this.
waitForRoomInSync(String roomId, {bool join = false, bool invite = false, bool leave = false}) Future<SyncUpdate>
Wait for the room to appear into the enabled section of the room sync. By default, the function will listen for room in invite, join and leave sections of the sync.

Operators

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