StreamNotifier<T>.result constructor

StreamNotifier<T>.result(
  1. FetchResultStream<T> fetch, {
  2. T? data,
  3. Result<T>? result,
  4. Duration? expiration,
  5. ResultNotifierCallback<T>? onReset,
  6. T onErrorReturn(
    1. Object? error
    )?,
})

Creates a StreamNotifier that uses the provided fetch function to fetch a Stream of Results on each refresh.

The fetched Stream will be subscribed to on each fetch, after unsubscribing from any previous Stream. Each data or error event will then be passed to this notifier.

If expiration (i.e. cache expiration) is specified, the data will be considered stale after the specified duration has elapsed since the last update, meaning isFresh will return false.

Optionally provide callbacks for onFetch and onReset, which are called when fetch (refresh) or reset (and also cancellation and disposal) occurs.

If onErrorReturn is specified, the specified value will be returned as data when an error occurs, meaning this ResultNotifier will never be able to enter the Error state.

If autoReset (willAutoReset) is true, this notifier will automatically reset itself when all listeners are removed.

If refreshOnError (willRefreshOnError) is true, the refresh method will fetch new data when the current state is Error.

Implementation

StreamNotifier.result(
  FetchResultStream<T> fetch, {
  super.data,
  super.result,
  super.expiration,
  super.onReset,
  super.onErrorReturn,
}) : super(onFetch: _onFetchResult(fetch));