ItemHolder<E extends Object> class
Item Holders
Enums
A basic implementation of ItemHolderApi for simple types.
This class provides a straightforward way to manage individual items
in a storage backend. It requires custom setter and getter functions
to handle the specific type E. This is useful for types that do not
require complex serialization, or when you want to manage the serialization
- Implemented types
- Implementers
Constructors
-
ItemHolder(BaseStorage _parent, String _key, {ItemGetter<
E> ? getter, ItemSetter<E> ? setter, List<Enum> ? enumValues}) - Creates a new ItemHolder instance.
Properties
-
exists
→ Future<
bool> -
Returns
trueif the item exists in the storage.no setteroverride -
first
→ Future<
E?> -
The first element of this stream.
no setterinherited
-
getter
→ ItemGetter<
E> ? -
Custom getter function to retrieve the item from the backend.
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Returns
trueif there are any listeners registeredno setteroverride - isBroadcast → bool
-
Whether this stream is a broadcast stream.
no setterinherited
- isClosed → bool
-
Whether this stream has been disposed and is no longer usable.
no setterinherited
-
isEmpty
→ Future<
bool> -
Whether this stream contains any elements.
no setterinherited
-
last
→ Future<
E?> -
The last element of this stream.
no setterinherited
-
length
→ Future<
int> -
The number of elements in this stream.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
-
setter
→ ItemSetter<
E> ? -
Custom setter function to store the item in the backend.
final
-
single
→ Future<
E?> -
The single element of this stream.
no setterinherited
-
streamController
→ BehaviorSubject<
E?> -
Protected getter for accessing the stream controller from subclasses.
no setterinherited
Methods
-
addListener(
ListenableCallback listener) → void -
Registers a listener to be called when any data changes.
override
-
any(
bool test(E? element)) → Future< bool> -
Checks whether
testaccepts any element provided by this stream.inherited -
asBroadcastStream(
{void onListen(StreamSubscription< E?> subscription)?, void onCancel(StreamSubscription<E?> subscription)?}) → Stream<E?> -
Returns a multi-subscription stream that produces the same events as this.
inherited
-
asyncExpand<
E> (Stream< E> ? convert(E? event)) → Stream<E> -
Transforms each element into a sequence of asynchronous events.
inherited
-
asyncMap<
E> (FutureOr< E> convert(E? event)) → Stream<E> -
Creates a new stream with each data event of this stream asynchronously
mapped to a new event.
inherited
-
cast<
R> () → Stream< R> -
Adapt this stream to be a
Stream<R>.inherited -
contains(
Object? needle) → Future< bool> -
Returns whether
needleoccurs in the elements provided by this stream.inherited -
dispose(
) → void - Disposes this stream and releases all resources.
-
distinct(
[bool equals(E? previous, E? next)?]) → Stream< E?> -
Skips data events if they are equal to the previous data event.
inherited
-
drain<
E> ([E? futureValue]) → Future< E> -
Discards all data on this stream, but signals when it is done or an error
occurred.
inherited
-
elementAt(
int index) → Future< E?> -
Returns the value of the
indexth data event of this stream.inherited -
emit(
E? event) → void -
Emits a value to all active listeners.
inherited
-
emitError(
Object error, [StackTrace? stackTrace]) → void -
Emits an error to all active listeners.
inherited
-
every(
bool test(E? element)) → Future< bool> -
Checks whether
testaccepts all elements provided by this stream.inherited -
expand<
S> (Iterable< S> convert(E? element)) → Stream<S> -
Transforms each element of this stream into a sequence of elements.
inherited
-
firstWhere(
bool test(E? element), {E? orElse()?}) → Future< E?> -
Finds the first element of this stream matching
test.inherited -
fold<
S> (S initialValue, S combine(S previous, E? element)) → Future< S> -
Combines a sequence of values by repeatedly applying
combine.inherited -
forEach(
void action(E? event)) → Future< void> -
Executes
actionon each element of this stream.inherited -
get(
) → Future< E?> -
Retrieves the item from the storage.
override
-
handleError(
Function onError, {bool test(dynamic error)?}) → Stream< E?> -
Creates a wrapper Stream that intercepts some errors from this stream.
inherited
-
join(
[String separator = ""]) → Future< String> -
Combines the string representation of elements into a single string.
inherited
-
lastWhere(
bool test(E? element), {E? orElse()?}) → Future< E?> -
Finds the last element in this stream matching
test.inherited -
listen(
void onData(E? event)?, {Function? onError, void onDone()?, bool? cancelOnError}) → StreamSubscription< E?> -
Subscribes to this stream and returns a StreamSubscription.
inherited
-
map<
S> (S convert(E? event)) → Stream< S> -
Transforms each element of this stream into a new stream event.
inherited
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onFirstListener(
) → void - Lifecycle hook called when the first listener subscribes to this stream.
-
onNewListener(
) → void - Lifecycle hook called every time a new listener subscribes to this stream.
-
onNoListeners(
) → void - Lifecycle hook called when the last listener unsubscribes from this stream.
-
pipe(
StreamConsumer< E?> streamConsumer) → Future -
Pipes the events of this stream into
streamConsumer.inherited -
reduce(
E? combine(E? previous, E? element)) → Future< E?> -
Combines a sequence of values by repeatedly applying
combine.inherited -
remove(
) → Future< void> -
Removes the item from the storage.
override
-
removeAllListeners(
) → void -
Removes all registered listeners..
override
-
removeListener(
ListenableCallback listener) → void -
Removes a previously registered listener.
override
-
set(
E value) → Future< void> -
Saves the item to the storage.
override
-
singleWhere(
bool test(E? element), {E? orElse()?}) → Future< E?> -
Finds the single element in this stream matching
test.inherited -
skip(
int count) → Stream< E?> -
Skips the first
countdata events from this stream.inherited -
skipWhile(
bool test(E? element)) → Stream< E?> -
Skip data events from this stream while they are matched by
test.inherited -
take(
int count) → Stream< E?> -
Provides at most the first
countdata events of this stream.inherited -
takeWhile(
bool test(E? element)) → Stream< E?> -
Forwards data events while
testis successful.inherited -
timeout(
Duration timeLimit, {void onTimeout(EventSink< E?> sink)?}) → Stream<E?> -
Creates a new stream with the same events as this stream.
inherited
-
toList(
) → Future< List< E?> > -
Collects all elements of this stream in a List.
inherited
-
toSet(
) → Future< Set< E?> > -
Collects the data of this stream in a Set.
inherited
-
toString(
) → String -
A string representation of this object.
inherited
-
transform<
S> (StreamTransformer< E?, S> streamTransformer) → Stream<S> -
Applies
streamTransformerto this stream.inherited -
where(
bool test(E? element)) → Stream< E?> -
Creates a new stream from this stream that discards some elements.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited