StateController<State> constructor

StateController<State>(
  1. State initialState
)

A StateController is similar to Controller but has no notion of events and relies on methods to emit new states.

Every StateController requires an initial state which will be the state of the StateController before emit has been called.

The current state of a StateController can be accessed via the state getter.

class CounterController extends StateController<int> {
  CounterController() : super(0);

  void increment() => emit(state + 1);
}

Implementation

StateController(State initialState) : super(initialState);