distinct method
Returns an observable that only emits when the value changes according
to isEqual (defaults to ==).
Consecutive equal values are suppressed.
Implementation
Observable<T> distinct([bool Function(T a, T b)? isEqual]) {
final eq = isEqual ?? (T a, T b) => a == b;
return _DerivedObservable<T, T>(
parent: this,
handler: (value, emit, state) {
if (!state.hasPrevious || !eq(state.previous as T, value)) {
state.hasPrevious = true;
state.previous = value;
emit(value);
}
},
);
}