setState method

  1. @internal
void setState(
  1. StateT newState
)

Update the exposed value of a provider and notify its listeners.

Listeners will only be notified if updateShouldNotify returns true.

This API is not meant for public consumption. Instead if a Ref needs to expose a way to update the state, the practice is to expose a getter/setter.

Implementation

@internal
void setState(StateT newState) {
  assert(
    () {
      _debugDidSetState = true;
      return true;
    }(),
    '',
  );
  final previousResult = getState();
  final result = _state = ResultData(newState);

  if (_didBuild) {
    _notifyListeners(result, previousResult);
  }
}