onResult method

  1. @useResult
VoidCallback onResult(
  1. void listener(
    1. Result<T> result
    )
)

Registers a listener (addListener) that will be invoked with the current Result (value).

Use the returned VoidCallback function to unsubscribe the listener (i.e. calls removeListener).

See also:

  • onData, onLoading, onError for more specific listeners.
  • when for a simple way to perform actions based on the type of the current Result, without registering a listener.

Implementation

@useResult
VoidCallback onResult(void Function(Result<T> result) listener) {
  void listenerFunc() => listener(value);
  addListener(listenerFunc);
  return () => removeListener(listenerFunc);
}