changeState method Null safety

Future<void> changeState(
  1. STATES_ENUM state,
  2. {Json? params,
  3. Object? data,
  4. bool resetData = false}
)

Change the current state

Each state change can be accompanied by params to be passed in a PluginEvent to state listeners. Additional data can also be provided to be made available to the current and all subsequent state listeners. The data can be removed by setting resetData to true.

Implementation

Future<void> changeState(STATES_ENUM state,
    {Json? params, Object? data, bool resetData = false}) async {
  Get.log('[$runtimeType] ${lastEvent.state} -> $state');
  if (resetData) await container.remove();
  if (data != null) await container.set(data);
  // emit minor state before event
  if (emitMinorEvents) {
    minorEvents(MinorPluginEvent(state: state, before: true));
  }
  // emit major state for event
  events(PluginEvent<STATES_ENUM>(state, params));
  // emit minor state after event
  if (emitMinorEvents) {
    minorEvents(MinorPluginEvent(state: state, after: true));
  }
}