when<TResult extends Object?> abstract method

TResult when<TResult extends Object?>({
  1. required TResult initial(),
  2. required TResult loading(),
  3. required TResult success(
    1. T value
    ),
  4. required TResult error(
    1. Object? error,
    2. StackTrace? stackTrace
    ),
})
override

Defines logic based on the current state.

when takes five methods as parameters that reflect each remote state. when the returned method gets called with a RemoteState state, the method matching the correct state gets called.

initial determines what to do if the state matches RemoteState.initial

loading determines what to do if the state matches RemoteState.loading

success determines what to do if the state matches RemoteState.success

error determines what to do if the state matches RemoteState.error

Implementation

TResult when<TResult extends Object?>({
  required TResult Function() initial,
  required TResult Function() loading,
  required TResult Function(T value) success,
  required TResult Function(Object? error, StackTrace? stackTrace) error,
});