local_storage/ny_local_storage library

Classes

JsonHelper
Json helper class
NyStorage
Base class to help manage local storage
StorageConfig
Storage configuration for Nylo. You can set the storage options for each platform. E.g. AndroidOptions, IOSOptions, LinuxOptions, WindowsOptions, WebOptions, MacOsOptions
StorageManager
Storage manager for Nylo.

Functions

isDouble(String? s) bool
Checks if the value is a double (must contain a decimal point). Returns false for integers - use isInteger to check for integers first.
isInteger(String? s) bool
Checks if the value is an integer.
objectToJson(dynamic object) Map<String, dynamic>?
Attempts to call toJson() on an object.
storageCollectionDeleteIndex<T>(String key, int index) Future<void>
Delete an item from a collection in the storage class.
storageCollectionDeleteValue<T>(String key, {required T value}) Future<void>
Delete a value from a collection in the storage class.
storageCollectionDeleteWhere<T>(String key, bool value(T where)) Future<void>
Delete an item from a collection in the storage class.
storageCollectionRead<T>(String key, {Map<Type, dynamic>? modelDecoders}) Future<List<T>>
Read a collection from the storage class.
storageCollectionSave<T>(String key, List<T> collection) Future<void>
Save a collection to the storage class.
storageDelete(String key) Future<void>
Delete data from the storage class.
storageDeleteMultiple(List<String> keys, {bool andFromBackpack = false}) Future<void>
Delete multiple keys from storage in batch.
storageGetTTL(String key) Future<Duration?>
Get the remaining time-to-live for a key with expiry.
storageHasKey(String key) Future<bool>
Check if a key exists in storage.
storageRead<T>(String key, {Map<Type, dynamic>? modelDecoders}) Future<T?>
Read data from the storage class. Returns the value cast to type T, or null if not found.
storageReadMultiple<T>(List<String> keys, {Map<Type, dynamic>? modelDecoders}) Future<Map<String, T?>>
Read multiple keys from storage in batch.
storageReadWithExpiry<T>(String key, {T? defaultValue, Map<Type, dynamic>? modelDecoders, bool deleteIfExpired = true}) Future<T?>
Read data from the storage class, respecting TTL expiration.
storageRemoveExpired() Future<int>
Remove all expired keys from storage.
storageSave(String key, dynamic object, {bool inBackpack = false}) Future<void>
Save data to the storage class.
storageSaveAll(Map<String, dynamic> items, {bool inBackpack = false}) Future<void>
Save multiple key-value pairs to storage in batch.
storageSaveWithExpiry(String key, dynamic object, {required Duration ttl, bool inBackpack = false}) Future<void>
Save data to the storage class with an expiration time.

Exceptions / Errors

StorageDeserializationException
Exception thrown when deserialization of stored data fails.
StorageException
Base exception class for storage-related errors.
StorageKeyNotFoundException
Exception thrown when a storage key is not found.
StorageSerializationException
Exception thrown when serialization of an object to storage fails.
StorageTimeoutException
Exception thrown when a storage operation times out.