StateSubject<T> constructor
StateSubject<T> (})
Constructs a StateSubject, optionally pass handlers for
onListen
, onCancel
and a flag to handle events sync
.
seedValue
becomes the current value of Subject.
equals
is used to determine equality between previous data event and current data event.
See also StreamController.broadcast, ValueSubject.
Implementation
factory StateSubject(
T seedValue, {
Equality<T>? equals,
void Function()? onListen,
FutureOr<void> Function()? onCancel,
bool sync = false,
}) {
final controller = StreamController<T>.broadcast(
onListen: onListen,
onCancel: onCancel,
sync: sync,
);
return StateSubject._(
seedValue,
equals ?? StateStream.defaultEquality,
controller,
);
}