changeState method Null safety
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));
}
}