when<TResult extends Object?> abstract method
TResult
when<TResult extends Object?>({
- required TResult initial(),
- required TResult loading(),
- required TResult success(
- T value
- required TResult error(
- Object? error,
- 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,
});