SideEffects<T>.onError constructor

SideEffects<T>.onError(
  1. void onError(
    1. dynamic err,
    2. VoidCallback refresh
    ), {
  2. void initState()?,
  3. void dispose()?,
})

Side effect to be called when the state has error.

Implementation

factory SideEffects.onError(
  void Function(dynamic err, VoidCallback refresh) onError, {
  void Function()? initState,
  void Function()? dispose,
}) {
  return SideEffects(
    initState: initState,
    dispose: dispose,
    onSetState: (snap) {
      if (snap.hasError) {
        onError(snap.snapError!.error, snap.snapError!.refresher);
      }
    },
  );
}