cancel method

void cancel({
  1. bool always = false,
})

Cancels the current data loading operation, if any.

If (and only if) the current state is Loading (i.e. isLoading), the refresh operation is cancelled by setting the value to Error.cancelled. If specified, the onReset function will also be invoked.

If always is true, cancellation will happen regardless of the current state.

Implementation

void cancel({bool always = false}) {
  if (isLoading || always) {
    value = value.toCancelled();
    onReset?.call(this);
  }
}