BehaviorSubject<T>.seeded constructor Null safety

  1. T seedValue,
  2. {void onListen(
    1. void onCancel(
      1. bool sync = false}

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

      seedValue becomes the current value and is emitted immediately.

      See also StreamController.broadcast


      factory BehaviorSubject.seeded(
        T seedValue, {
        void Function()? onListen,
        void Function()? onCancel,
        bool sync = false,
      }) {
        // ignore: close_sinks
        final controller = StreamController<T>.broadcast(
          onListen: onListen,
          onCancel: onCancel,
          sync: sync,
        final wrapper = _Wrapper<T>.seeded(seedValue);
        return BehaviorSubject<T>._(
          Rx.defer<T>(_deferStream(wrapper, controller, sync), reusable: true),