StreamSubscriptionNotifier<T> constructor
- StreamSubscription<
T> _sub, { - bool ignoreError = false,
- bool cancelOnDispose = true,
- bool cancelOnError = false,
- bool cancelOnDone = false,
A StreamSubscriptionNotifier exposes a StreamSubscription to a ChangeNotifier.
Everytime the StreamSubscription.onData callback gets called the value of this is set to the bew data from StreamSubscription.onData.
When the StreamSubscription.onError callback gets called and
ignoreError and cancelOnError are false
this
StreamSubscriptionNotifier removes all it's handlers. Afterwards this
StreamSubscriptionNotifier can no longer emit updates because it does
not listen to the StreamSubscription anymore.
When the StreamSubscription.onDone callback gets called and
cancelOnDone is false
this StreamSubscriptionNotifier removes all
it's handlers. Afterwards this StreamSubscriptionNotifier can no longer
emit updates because it does not listen to the StreamSubscription
anymore.
Implementation
StreamSubscriptionNotifier(
StreamSubscription<T> this._sub, {
this.ignoreError = false,
this.cancelOnDispose = true,
this.cancelOnError = false,
this.cancelOnDone = false,
}) : _onErrorNotifier = EmptyValueNotifier.empty(),
_isDoneNotifier = AdvancedValueNotifier(false),
_isCancelledNotifier = AdvancedValueNotifier(false),
_hasValue = false,
assert(
!ignoreError || (ignoreError && !cancelOnError),
"cancelOnError cannot be true, "
"if you want to ignore incoming errors.") {
_sub!
..onError(_onError)
..onDone(_onDone)
..onData(_onData);
}