setState method

  1. @protected
void setState(
  1. S update,
  2. {String? event}
)

Called by blocs (subclasses) when the state is updated

isBusy and error are cleared whenever the state is updated Optional argument event is the name of event which is calling setState

Implementation

@protected
void setState(S update, {String? event}) {
  assert(isValueType(update));
  final _stream = this._stream;
  _monitor.onEvent(runtimeType.toString(), _state, update, event: event);
  _isBusy = false;
  _error = null;
  final next = nextState(_state, update);

  if (next == null) {
    return;
  }

  _state = next;
  if (_stream != null) {
    _stream.add(_state);
    _monitor.onBroadcast(runtimeType.toString(), _state, event: event);
  }
}