JsonStore class Null safety


JsonStore({Database? database, Directory? dbLocation, String dbName = 'json_store', bool inMemory = false})
create instance of your singleton JsonStore database If you need to supply your own database for whatever reason (maybe mocking or something) dbLocation If you want to use a different location for the DB file (default: ApplicationDocumentsDirectory) dbName Provide a custom database file name (default: json_store) inMemory If you don't want to store to disk but rather have it all in memory (default: false)


hashCode int
The hash code for this object.
runtimeType Type
A representation of the runtime type of the object.


clearDataBase() Future<void>
commitBatch(Batch batch) Future<void>
deleteItem(String key, {Batch? batch}) Future<void>
deleteLike(String key, {Batch? batch}) Future<void>
getItem(String key) Future<Map<String, dynamic>?>
Function that will retrieve a single json object from the database.
getItemLike(String key) Future<Map<String, dynamic>?>
getListLike(String key) Future<List<Map<String, dynamic>>?>
Function to retrieve a list of objects from the database stored under a similar key. example: Message list could be retrieved like this await jsonStore.getListLike('message%'); //this should return a list based on the following data | key | value | | message-1 | ... | | message-2 | ... | | message-3 | ... |
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
setItem(String key, Map<String, dynamic> value, {bool encrypt = encryptByDefault, Duration? timeToLive, Batch? batch}) Future<void>
This function will store any data as a single json object in the database. We will try and update the key first and then insert if none exists key the key of your item used to be retrieved later value json Map of your value object encrypt should the value be encrypted (default: false) timeToLive how long should the data be considered valid (default: null) If you getItem and the TTL has expired null will be returned and it will be removed from the database if timeToLive is null the data will never expire batch for transaction control where many setItem operations can be done in batch and commited at the end. see startBatch
startBatch() Future<Batch>
This function will create a Batch object, this allowed you to do some sort of transaction control. example: var b = await jsonStore.startBatch(); await jsonStore.setItem('key', value1, batch: b); await jsonStore.setItem('key', value2, batch: b); await jsonStore.setItem('key', value3, batch: b); await jsonStore.commitBatch(b);
toString() String
A string representation of this object.


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


encryptByDefault → const bool