updateState method

void updateState(
  1. DiveCoreElementsState onChangeState(
    1. DiveCoreElementsState state
    )
)

Update the current state. Changes to this state are saved and are sent to notifiers. This method is good for making many state changes, and then having only one change sent the notifiers.

Implementation

void updateState(DiveCoreElementsState Function(DiveCoreElementsState state) onChangeState) {
  final controller = DiveCore.container.read(provider.notifier);
  final currentState = controller.state;
  final newState = onChangeState(currentState);
  final isEqual = newState == currentState;
  assert(!isEqual, 'why are these states equal?');
  controller.state = newState;
}