removeStateByStateName method

void removeStateByStateName (
  1. String stateName,
  2. [bool shouldDispatch = true]
)

This method is usefull to remove a state passing stateName on demand.

Implementation

void removeStateByStateName(String stateName, [bool shouldDispatch = true]) {
  var index = _states.indexWhere((bs) => bs.name == stateName);
  if (index != -1) {
    _states.removeAt(index);
    if (shouldDispatch) {
      //dispatch(Action(type: 'remove_state(${stateName})'));
      _action = Action(type: 'remove_state(${stateName})');
      var state = value;
      state.remove(stateName);
      _store.add(state);
    }
  }
}