serializableStream<E extends Object> method

Stream<E?> serializableStream<E extends Object>(
  1. String key, {
  2. required SerializeCallback<E> serialize,
  3. required DeserializeCallback<E> deserialize,
})

Provides a Stream of custom-serializable objects for the given key.

This method returns a SerializableItemHolder which handles custom serialization logic. Like stream, it returns a cached instance and is safe for use with StreamBuilder.

Use this when you need custom serialization beyond JSON (e.g., Protocol Buffers, CSV, XML, etc.).

Example:

final configStream = storage.serializableStream<Config>(
  'appConfig',
  serialize: (config) => config.toCustomFormat(),
  deserialize: (data) => Config.fromCustomFormat(data),
);

Parameters:

  • key - The storage key to stream objects for
  • serialize - Function to serialize object of type E to String
  • deserialize - Function to deserialize String to object of type E

Returns: A broadcast Stream that emits the current object and all future changes.

See also:

Implementation

Stream<E?> serializableStream<E extends Object>(
  String key, {
  required SerializeCallback<E> serialize,
  required DeserializeCallback<E> deserialize,
}) => serializableItemHolder<E>(key, serialize: serialize, deserialize: deserialize);