setValue method

void setValue(
  1. void updateFn(
    1. T? currentValue
    )
)

Executes the provided updateFn and then re-emits the updated value on the stream. Consider the following example where the current value is updated:

final userBloc = StateBloc(UserModel(name: 'Luke'));
userBloc.setValue((user) => user.name = "Luke Skywalker");

setValue will re-emit the user object on the stream, allowing all listeners to receive the updated value.

Implementation

void setValue(void Function(T? currentValue) updateFn) {
  updateFn(_value);
  add(_value);
}