MatrixSdkDatabase class

Database based on SQlite3 on native and IndexedDB on web. For native you have to pass a Database object, which can be created with the sqflite package like this:

final database = await openDatabase('path/to/your/database');

WARNING: For android it seems like that the CursorWindow is too small for large amounts of data if you are using SQFlite. Consider using a different package to open the database like sqflite_sqlcipher or sqflite_common_ffi. Learn more at: https://github.com/famedly/matrix-dart-sdk/issues/1642#issuecomment-1865827227

Inheritance

Constructors

MatrixSdkDatabase(String name, {Database? database, dynamic idbFactory, DatabaseFactory? sqfliteFactory, int maxFileSize = 0, @Deprecated('Breaks support for web standalone. Use [fileStorageLocation] instead.') dynamic fileStoragePath, Uri? fileStorageLocation, Duration? deleteFilesAfterDuration})

Properties

database ↔ Database?
getter/setter pair
deleteFilesAfterDuration Duration?
latefinalinherited
fileStorageLocation Uri?
latefinalinherited
fileStoragePath Object?
no setter
hashCode int
The hash code for this object.
no setterinherited
idbFactory → dynamic
Custom IdbFactory used to create the indexedDB. On IO platforms it would lead to an error to import "dart:indexed_db" so this is dynamically typed.
final
maxFileSize int
final
name String
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
sqfliteFactory → DatabaseFactory?
Custom SQFlite Database Factory used for high level operations on IO like delete. Set it if you want to use sqlite FFI.
final
supportsFileStoring bool
no setterinherited

Methods

addSeenDeviceId(String userId, String deviceId, String publicKeys) Future<void>
override
addSeenPublicKey(String publicKey, String deviceId) Future<void>
override
clear() Future<void>
override
clearCache() Future<void>
override
clearSSSSCache() Future<void>
override
close() Future<void>
override
delete() Future<void>
Deletes the whole database. The database needs to be created again after this. Used for migration only.
override
deleteFromToDeviceQueue(int id) Future<void>
override
deleteOldFiles(int savedAt) Future<void>
inherited
deleteTimelineForRoom(String roomId) Future<void>
override
deviceIdSeen(dynamic userId, dynamic deviceId) Future<String?>
override
exportDump() Future<String>
override
forgetRoom(String roomId) Future<void>
override
getAccountData() Future<Map<String, BasicEvent>>
override
getAllInboundGroupSessions() Future<List<StoredInboundGroupSession>>
override
getAllOlmSessions() Future<Map<String, Map>>
override
getClient(String name) Future<Map<String, dynamic>?>
override
getEventById(String eventId, Room room) Future<Event?>
override
getEventIdList(Room room, {int start = 0, bool includeSending = false, int? limit}) Future<List<String>>
override
getEventList(Room room, {int start = 0, bool onlySending = false, int? limit}) Future<List<Event>>
override
getFile(Uri mxcUri) Future<Uint8List?>
inherited
getInboundGroupSession(String roomId, String sessionId) Future<StoredInboundGroupSession?>
override
getInboundGroupSessionsToUpload() Future<List<StoredInboundGroupSession>>
override
getLastSentMessageUserDeviceKey(String userId, String deviceId) Future<List<String>>
override
getOlmSessions(String identityKey, String userId) Future<List<OlmSession>>
override
getOlmSessionsForDevices(List<String> identityKeys, String userId) Future<List<OlmSession>>
override
getOutboundGroupSession(String roomId, String userId) Future<OutboundGroupSession?>
override
getPresence(String userId) Future<CachedPresence?>
override
getRoomList(Client client) Future<List<Room>>
override
getSingleRoom(Client client, String roomId, {bool loadImportantStates = true}) Future<Room?>
override
getSSSSCache(String type) Future<SSSSCache?>
override
getToDeviceEventQueue() Future<List<QueuedToDeviceEvent>>
override
getUnimportantRoomEventStatesForRoom(List<String> events, Room room) Future<List<Event>>
override
getUser(String userId, Room room) Future<User?>
override
getUserDeviceKeys(Client client) Future<Map<String, DeviceKeysList>>
override
getUsers(Room room) Future<List<User>>
override
importDump(String export) Future<bool>
override
insertClient(String name, String homeserverUrl, String token, DateTime? tokenExpiresAt, String? refreshToken, String userId, String? deviceId, String? deviceName, String? prevBatch, String? olmAccount) Future<int>
override
insertIntoToDeviceQueue(String type, String txnId, String content) Future<int>
Please do jsonEncode(content) in your code to stay compatible with auto generated methods here.
override
markInboundGroupSessionAsUploaded(String roomId, String sessionId) Future<void>
override
markInboundGroupSessionsAsNeedingUpload() Future<void>
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
open() Future<void>
publicKeySeen(String publicKey) Future<String?>
override
removeEvent(String eventId, String roomId) Future<void>
override
removeOutboundGroupSession(String roomId) Future<void>
override
removeUserCrossSigningKey(String userId, String publicKey) Future<void>
override
removeUserDeviceKey(String userId, String deviceId) Future<void>
override
setBlockedUserCrossSigningKey(bool blocked, String userId, String publicKey) Future<void>
override
setBlockedUserDeviceKey(bool blocked, String userId, String deviceId) Future<void>
override
setLastActiveUserDeviceKey(int lastActive, String userId, String deviceId) Future<void>
override
setLastSentMessageUserDeviceKey(String lastSentMessage, String userId, String deviceId) Future<void>
override
setRoomPrevBatch(String? prevBatch, String roomId, Client client) Future<void>
override
setVerifiedUserCrossSigningKey(bool verified, String userId, String publicKey) Future<void>
override
setVerifiedUserDeviceKey(bool verified, String userId, String deviceId) Future<void>
override
storeAccountData(String type, String content) Future<void>
override
storeEventUpdate(EventUpdate eventUpdate, Client client) Future<void>
Stores an EventUpdate object in the database. Must be called inside of transaction.
override
storeFile(Uri mxcUri, Uint8List bytes, int time) Future<void>
inherited
storeInboundGroupSession(String roomId, String sessionId, String pickle, String content, String indexes, String allowedAtIndex, String senderKey, String senderClaimedKey) Future<void>
override
storeOlmSession(String identityKey, String sessionId, String pickle, int lastReceived) Future<void>
override
storeOutboundGroupSession(String roomId, String pickle, String deviceIds, int creationTime) Future<void>
override
storePresence(String userId, CachedPresence presence) Future<void>
override
storePrevBatch(String prevBatch) Future<void>
override
storeRoomUpdate(String roomId, SyncRoomUpdate roomUpdate, Event? lastEvent, Client client) Future<void>
Stores a RoomUpdate object in the database. Must be called inside of transaction.
override
storeSSSSCache(String type, String keyId, String ciphertext, String content) Future<void>
override
storeSyncFilterId(String syncFilterId) Future<void>
override
storeUserCrossSigningKey(String userId, String publicKey, String content, bool verified, bool blocked) Future<void>
override
storeUserDeviceKey(String userId, String deviceId, String content, bool verified, bool blocked, int lastActive) Future<void>
override
storeUserDeviceKeysInfo(String userId, bool outdated) Future<void>
override
toString() String
A string representation of this object.
inherited
transaction(Future<void> action()) Future<void>
override
updateClient(String homeserverUrl, String token, DateTime? tokenExpiresAt, String? refreshToken, String userId, String? deviceId, String? deviceName, String? prevBatch, String? olmAccount) Future<void>
override
updateClientKeys(String olmAccount) Future<void>
override
updateInboundGroupSessionAllowedAtIndex(String allowedAtIndex, String roomId, String sessionId) Future<void>
override
updateInboundGroupSessionIndexes(String indexes, String roomId, String sessionId) Future<void>
override

Operators

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

Constants

version → const int