DistinctValueSubject<T> constructor

DistinctValueSubject<T>(
  1. T seedValue, {
  2. bool equals(
    1. T p1,
    2. T p2
    )?,
  3. void onListen()?,
  4. FutureOr<void> onCancel()?,
  5. bool sync = false,
})

Constructs a DistinctValueSubject, 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 DistinctValueSubject(
  T seedValue, {
  bool Function(T p1, T p2)? equals,
  void Function()? onListen,
  FutureOr<void> Function()? onCancel,
  bool sync = false,
}) {
  final subject = ValueSubject<T>(
    seedValue,
    onListen: onListen,
    onCancel: onCancel,
    sync: sync,
  );
  return DistinctValueSubject._(
      equals ?? DistinctValueStream.defaultEquals, subject);
}