createStreamProperty<T> method

StreamProperty<T> createStreamProperty<T>(
  1. Stream<T> initialValue, {
  2. VoidCallback? listener,
})

Creates a StreamProperty and adds a listener.

listener is the listener to add. If listener is null, Model.notifyListeners is used.

Requires the late keyword when used during initialization:

late final counter = createStreamProperty

If a stream is required with no initial listeners, instantiate a StreamProperty instead:

final counter = StreamProperty

Implementation

StreamProperty<T> createStreamProperty<T>(Stream<T> initialValue,
    {VoidCallback? listener}) {
  final streamProperty = StreamProperty<T>(initialValue);
  streamProperty.addListener(listener ?? notifyListeners);
  return streamProperty;
}