ValueSubject<T>.initialValue constructor

ValueSubject<T>.initialValue(
  1. T initialValue, {
  2. bool sync = false,
})

Constructs a new ValueSubject seeded with an initial value.

After construction, hasValue will be true and value will return initialValue.

Implementation

factory ValueSubject.initialValue(T initialValue, {bool sync = false}) {
  var controller = StreamController<T>.broadcast(sync: sync);
  var currentValue = _CurrentValue<T>();
  currentValue.setValue(initialValue);
  return ValueSubject._(controller, currentValue, sync);
}