JsonItemHolder<E extends Object> class
final
A JSON-based item holder for managing serialized items.
This class extends SerializableItemHolder to provide a convenient way to
store and retrieve items of type E using JSON serialization. It requires
custom fromJson and toJson functions to handle the conversion between
the Dart object and its JSON representation.
Type parameter:
E- The type of the item being stored. Must be serializable to and from JSON.
- Inheritance
-
- Object
- ItemHolder<
E> - SerializableItemHolder<
E> - JsonItemHolder
Constructors
-
JsonItemHolder(BaseStorage _backend, String _key, {required FromJson<
E> fromJson, required ToJson<E> toJson}) - Creates a new JsonItemHolder instance.
Properties
-
deserialize
→ DeserializeCallback<
E> -
Converter function to deserialize data into type
E.finalinherited -
exists
→ Future<
bool> -
Returns
trueif the item exists in the storage.no setterinherited -
first
→ Future<
E?> -
The first element of this stream.
no setterinherited
-
getter
→ ItemGetter<
E> ? -
Custom getter function to retrieve the item from the backend.
finalinherited
- hashCode → int
-
The hash code for this object.
no setterinherited
- hasListeners → bool
-
Returns
trueif there are any listeners registeredno setterinherited - 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
-
serialize
→ SerializeCallback<
E> -
Converter function to serialize type
Einto JSON.finalinherited -
setter
→ ItemSetter<
E> ? -
Custom setter function to store the item in the backend.
finalinherited
-
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.
inherited
-
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.
inherited
-
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.
inherited
-
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.
inherited
-
onNewListener(
) → void -
Lifecycle hook called every time a new listener subscribes to this stream.
inherited
-
onNoListeners(
) → void -
Lifecycle hook called when the last listener unsubscribes from this stream.
inherited
-
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.
inherited
-
removeAllListeners(
) → void -
Removes all registered listeners..
inherited
-
removeListener(
ListenableCallback listener) → void -
Removes a previously registered listener.
inherited
-
set(
E value) → Future< void> -
Saves the item to the storage.
inherited
-
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