onStateWillChange method

bool onStateWillChange(
  1. S oldState,
  2. S newState
)

this method is called when the state is going to be updated By default this method returns true, you can use this method to intercept the newState and check if the new state is valid. If this method returns false the new state will be igonored

Implementation

bool onStateWillChange(S oldState, S newState) => oldState != newState;