stepBody method
Builds the step body widget based on the answer format of each step.
Implementation
Widget stepBody(String id, RPAnswerFormat answerFormat) {
switch (answerFormat.runtimeType) {
case RPIntegerAnswerFormat:
return RPUIIntegerQuestionBody((answerFormat as RPIntegerAnswerFormat),
(result) {
RPStepResult tempResult = stepResult?.results[id] as RPStepResult;
tempResult.questionTitle = widget.formStep.questions
.where((step) => step.identifier == id)
.first
.title;
tempResult.setResult(result);
checkReadyToProceed();
});
case RPDoubleAnswerFormat:
return RPUIDoubleQuestionBody((answerFormat as RPDoubleAnswerFormat),
(result) {
RPStepResult tempResult = stepResult?.results[id] as RPStepResult;
tempResult.questionTitle = widget.formStep.questions
.where((step) => step.identifier == id)
.first
.title;
tempResult.setResult(result);
checkReadyToProceed();
});
case RPChoiceAnswerFormat:
return RPUIChoiceQuestionBody((answerFormat as RPChoiceAnswerFormat),
(result) {
RPStepResult tempResult = stepResult?.results[id] as RPStepResult;
tempResult.questionTitle = widget.formStep.questions
.where((step) => step.identifier == id)
.first
.title;
tempResult.setResult(result);
checkReadyToProceed();
});
case RPSliderAnswerFormat:
return RPUISliderQuestionBody((answerFormat as RPSliderAnswerFormat),
(result) {
RPStepResult tempResult = stepResult?.results[id] as RPStepResult;
tempResult.questionTitle = widget.formStep.questions
.where((step) => step.identifier == id)
.first
.title;
tempResult.setResult(result);
checkReadyToProceed();
});
case RPImageChoiceAnswerFormat:
return RPUIImageChoiceQuestionBody(
(answerFormat as RPImageChoiceAnswerFormat), (result) {
RPStepResult tempResult = stepResult?.results[id] as RPStepResult;
tempResult.questionTitle = widget.formStep.questions
.where((step) => step.identifier == id)
.first
.title;
tempResult.setResult(result);
checkReadyToProceed();
});
case RPDateTimeAnswerFormat:
return RPUIDateTimeQuestionBody(
(answerFormat as RPDateTimeAnswerFormat), (result) {
RPStepResult tempResult = stepResult?.results[id] as RPStepResult;
tempResult.questionTitle = widget.formStep.questions
.where((step) => step.identifier == id)
.first
.title;
tempResult.setResult(result);
checkReadyToProceed();
});
case RPTextAnswerFormat:
return RPUITextInputQuestionBody((answerFormat as RPTextAnswerFormat),
(result) {
RPStepResult tempResult = stepResult?.results[id] as RPStepResult;
tempResult.questionTitle = widget.formStep.questions
.where((step) => step.identifier == id)
.first
.title;
tempResult.setResult(result);
stepResult?.results[id] = tempResult;
checkReadyToProceed();
});
default:
return Container();
}
}