HyperStorageContainer class final Containers

A concrete implementation of StorageContainer for storing key-value pairs.

HyperStorageContainer provides a complete, production-ready implementation of the storage container API. It handles all primitive data types, collections, and special types like DateTime and Duration. The container manages key encoding/decoding, notification of listeners, and validation of all operations.

Key Validation

All keys are validated before operations:

  • Keys cannot be empty
  • Keys cannot contain only whitespace
  • Keys are checked by validateKey before any operation

See also:

  • StorageContainer for the base class and abstract interface
Inheritance
Implemented types
Mixed-in types

Constructors

HyperStorageContainer({required StorageBackend backend, required String name, String? delimiter})
Creates a new HyperStorageContainer instance.

Properties

delimiter → String
The character(s) used to separate the container name from the key.
finalinherited
hashCode → int
The hash code for this object.
no setterinherited
hasListeners → bool
Returns true if there are any listeners registered (global or keyed).
no setterinherited
isEmpty → Future<bool>
Returns true if the storage contains no key-value pairs.
no setterinherited
isNotEmpty → Future<bool>
Returns true if the storage contains one or more key-value pairs.
no setterinherited
name → String
The name of the storage container, used for namespacing keys.
finalinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

addKeyListener(String key, ListenableCallback listener) → void
Registers a listener to be called when data for a specific key changes.
inherited
addListener(ListenableCallback listener) → void
Registers a global listener to be called when any data in the storage changes.
inherited
clear() → Future<void>
Clears all data stored in this container.
close() → Future<void>
Closes the container and releases any resources.
containsKey(String key) → Future<bool>
Returns true if a value with the given key exists in the storage.
override
customItemHolder<H extends ItemHolder<E>, E extends Object>(String key, {required H create(StorageBackend backend, String key)}) → H
Creates a custom item holder using the provided factory function.
inherited
get<E extends Object>(String key, {List<Enum>? enumValues}) → Future<E?>
Retrieves a value of type E by its key.
inherited
getAll([Iterable<String>? allowList]) → Future<Map<String, dynamic>>
Retrieves all key-value pairs from the storage.
override
getBool(String key) → Future<bool?>
Retrieves a bool value by its key.
override
getBytes(String key) → Future<Uint8List?>
Retrieves a byte array by its key.
override
getDateTime(String key, {bool isUtc = false}) → Future<DateTime?>
Retrieves a DateTime value by its key.
override
getDecodedKeys() → Future<Set<String>>
Returns a set of all decoded keys in the container.
inherited
getDouble(String key) → Future<double?>
Retrieves a double value by its key.
override
getDuration(String key) → Future<Duration?>
Retrieves a Duration value by its key.
override
getEncodedKeys() → Future<Set<String>>
Returns a set of all encoded keys in the container.
inherited
getEnum<E extends Enum>(String key, List<E> values) → Future<E?>
Retrieves an enum value of type E by its key.
override
getInt(String key) → Future<int?>
Retrieves an int value by its key.
override
getJson(String key) → Future<Map<String, dynamic>?>
Retrieves a JSON object by its key.
override
getJsonList(String key) → Future<List<Map<String, dynamic>>?>
Retrieves a list of JSON objects by its key.
override
getKeys() → Future<Set<String>>
Returns a set of all keys currently stored in the storage.
override
getString(String key) → Future<String?>
Retrieves a String value by its key.
override
getStringList(String key) → Future<List<String>?>
Retrieves a list of strings by its key.
override
hasKeyListeners(String key) → bool
Returns true if there are any listeners registered for the given key.
inherited
itemHolder<E extends Object>(String key, {ItemGetter<E>? get, ItemSetter<E>? set, List<Enum>? enumValues}) → ItemHolder<E>
Creates an item holder for storing a single primitive value at the specified key.
inherited
jsonItemHolder<E extends Object>(String key, {required FromJson<E> fromJson, required ToJson<E> toJson}) → JsonItemHolder<E>
Creates an item holder for storing a single serializable object at the specified key.
inherited
jsonStream<E extends Object>(String key, {required FromJson<E> fromJson, required ToJson<E> toJson}) → Stream<E?>
Provides a Stream of JSON-serializable objects for the given key.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyKeyListeners(String key) → void
Notifies all listeners that are registered for a specific key.
inherited
notifyListeners([String? key]) → void
Notifies all registered listeners of a change.
inherited
remove(String key) → Future<void>
Removes a value by its key.
override
removeAll(Iterable<String> keys) → Future<void>
Removes multiple values by their keys in a single operation.
override
removeAllKeyListeners(String key) → void
Removes all listeners registered for a specific key.
inherited
removeAllListeners() → void
Removes all registered listeners, both global and key-specific.
inherited
removeKeyListener(String key, ListenableCallback listener) → void
Removes a previously registered key-specific listener.
inherited
removeListener(ListenableCallback listener) → void
Removes a previously registered global listener.
inherited
serializableItemHolder<E extends Object>(String key, {required SerializeCallback<E> serialize, required DeserializeCallback<E> deserialize}) → SerializableItemHolder<E>
Creates an item holder for storing a single serializable object at the specified key.
inherited
serializableStream<E extends Object>(String key, {required SerializeCallback<E> serialize, required DeserializeCallback<E> deserialize}) → Stream<E?>
Provides a Stream of custom-serializable objects for the given key.
set<E extends Object>(String key, E value) → Future<void>
Saves a value of type E with the given key.
inherited
setAll(Map<String, dynamic> values) → Future<void>
Saves multiple key-value pairs from a Map in a single operation.
override
setBool(String key, bool value) → Future<void>
Saves a bool value with the given key.
override
setBytes(String key, Uint8List bytes) → Future<void>
Saves a byte array with the given key.
override
setDateTime(String key, DateTime value) → Future<void>
Saves a DateTime value with the given key.
override
setDouble(String key, double value) → Future<void>
Saves a double value with the given key.
override
setDuration(String key, Duration value) → Future<void>
Saves a Duration value with the given key.
override
setEnum<E extends Enum>(String key, E value) → Future<void>
Saves an enum value of type E with the given key.
override
setInt(String key, int value) → Future<void>
Saves an int value with the given key.
override
setJson(String key, Map<String, dynamic> value) → Future<void>
Saves a JSON object (Map) with the given key.
override
setJsonList(String key, List<Map<String, dynamic>> value) → Future<void>
Saves a list of JSON objects with the given key.
override
setString(String key, String value) → Future<void>
Saves a String value with the given key.
override
setStringList(String key, List<String> value) → Future<void>
Saves a list of strings with the given key.
override
stream<E extends Object>(String key, {List<Enum>? enumValues}) → Stream<E?>
Provides a Stream of values for the given key within this container.
toString() → String
A string representation of this object.
inherited
validateKeys(Iterable<String>? keys) → void
Validates a collection of storage keys to ensure they all meet requirements.
inherited
validateName(String name) → void
Validates the given container name to ensure it meets requirements.
inherited

Operators

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