onEvent method

void onEvent(
  1. SurveyEvent event
)

Implementation

void onEvent(SurveyEvent event) {
  if (event is StartSurvey) {
    final newState = _handleInitialStep();
    updateState(newState);
    navigatorKey.currentState?.pushNamed(
      '/',
      arguments: newState,
    );
  } else if (event is NextStep) {
    if (state is PresentingSurveyState) {
      final newState = _handleNextStep(event, state as PresentingSurveyState);
      updateState(newState);
      navigatorKey.currentState?.pushNamed(
        '/',
        arguments: newState,
      );
    }
  } else if (event is StepBack) {
    if (state is PresentingSurveyState) {
      final newState = _handleStepBack(event, state as PresentingSurveyState);
      updateState(newState);
      navigatorKey.currentState?.pop();
    }
  } else if (event is CloseSurvey) {
    if (state is PresentingSurveyState) {
      final newState = _handleClose(event, state as PresentingSurveyState);
      updateState(newState);
      navigatorKey.currentState?.pop();
    }
  }
}