BlocStateController<S extends BlocState>.withState constructor

BlocStateController<S extends BlocState>.withState(BlocState state)

Initializes the controller with a state. If the state argument is null, the value of initialState is used.

Implementation

BlocStateController.withState(BlocState state) : super() {
  if (state != null) {
    registerState(state);
  } else if (initialState != null) {
    registerState(initialState);
  } else {
    throw StateError(
        'A class that implements `BlocControllerWithState` must have ' +
            'an initial state either by providing the `withState` constructor ' +
            'with a state object or by overriding the `initialState` ' +
            'getter property.');
  }
}