addStateSource<S> method

  1. @protected
StreamSubscription<S>? addStateSource<S>(
  1. Future<S> source, {
  2. void onData(
    1. S data
    )?,
  3. void onDone()?,
  4. void onError(
    1. dynamic error
    )?,
})

Adds Future that should be returned by state of S type as source of state.

Callbacks onData, onDone, onError provide possibility to handle source. Throws ArgumentError if state of such type was not registered. Returns StreamSubscription that provide possibility to pause, resume or cancel source. Returns null if this Bloc was disposed.

Implementation

@protected
StreamSubscription<S>? addStateSource<S>(Future<S> source,
        {void Function(S data)? onData,
        void Function()? onDone,
        void Function(dynamic error)? onError}) =>
    addStatesSource(source.asStream(),
        onData: onData, onDone: onDone, onError: onError);