publish method

StreamController<T> publish([
  1. bool isBroadcast = false
])

Implementation

StreamController<T> publish([bool isBroadcast = false]) {
  StreamController<T>? _controller;
  final _onNotify = () {
    _controller?.add(this.value);
  };
  final _onCancel = () {
    removeListener(_onNotify);
  };
  _controller = isBroadcast
      ? StreamController.broadcast(onCancel: _onCancel)
      : StreamController(onCancel: _onCancel);
  addListener(_onNotify);
  return _controller;
}