ItemHolderMixin mixin

A mixin that provides item holder creation methods for a storage and containers.

This mixin is intended to be used with classes that implement ListenableStorage and have a StorageBackend. It provides methods to create various types of item holders, including JSON-serializable, generic serializable, and primitive type holders. Each item holder is automatically linked to the container's change notification system.

Superclass constraints
Mixin applications

Properties

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
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
close() → Future<void>
Disposes all item holders created by this mixin.
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.
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.
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.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
notifyListeners([String? key]) → void
Notifies all registered listeners of a change.
inherited
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.
toString() → String
A string representation of this object.
inherited

Operators

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