ValueSubject<T> constructor

ValueSubject<T>(
  1. T seedValue, {
  2. void onListen()?,
  3. void onCancel()?,
  4. bool sync = false,
})

Constructs a ValueSubject, optionally pass handlers for onListen, onCancel and a flag to handle events sync.

seedValue becomes the current value of Subject.

See also StreamController.broadcast.

Implementation

factory ValueSubject(
  T seedValue, {
  void Function()? onListen,
  void Function()? onCancel,
  bool sync = false,
}) {
  final controller = StreamController<T>.broadcast(
    onListen: onListen,
    onCancel: onCancel,
    sync: sync,
  );

  return ValueSubject._(
    controller,
    StreamEvent.data(seedValue),
  );
}