createView method

  1. @override
Widget createView({
  1. required QuestionResult? questionResult,
})
override

Implementation

@override
Widget createView({required QuestionResult? questionResult}) {
  final key = ObjectKey(this.stepIdentifier.id);

  switch (answerFormat.runtimeType) {
    case IntegerAnswerFormat:
      return IntegerAnswerView(
        key: key,
        questionStep: this,
        result: questionResult as IntegerQuestionResult?,
      );
    case DoubleAnswerFormat:
      return DoubleAnswerView(
        key: key,
        questionStep: this,
        result: questionResult as DoubleQuestionResult?,
      );
    case TextAnswerFormat:
      return TextAnswerView(
        key: key,
        questionStep: this,
        result: questionResult as TextQuestionResult?,
      );
    case SingleChoiceAnswerFormat:
      FocusManager.instance.primaryFocus?.unfocus();
      return SingleChoiceAnswerView(
        key: key,
        questionStep: this,
        result: questionResult as SingleChoiceQuestionResult?,
      );
    case MultipleChoiceAnswerFormat:
      return MultipleChoiceAnswerView(
        key: key,
        questionStep: this,
        result: questionResult as MultipleChoiceQuestionResult?,
      );
    case ScaleAnswerFormat:
      return ScaleAnswerView(
        key: key,
        questionStep: this,
        result: questionResult as ScaleQuestionResult?,
      );
    case BooleanAnswerFormat:
      return BooleanAnswerView(
        key: key,
        questionStep: this,
        result: questionResult as BooleanQuestionResult?,
      );
    case DateAnswerFormat:
      return DateAnswerView(
        key: key,
        questionStep: this,
        result: questionResult as DateQuestionResult?,
      );
    case TimeAnswerFormat:
      return TimeAnswerView(
        key: key,
        questionStep: this,
        result: questionResult as TimeQuestionResult?,
      );
    case MultipleDoubleAnswerFormat:
      return MultipleDoubleAnswerView(
        key: key,
        questionStep: this,
        result: questionResult as MultipleDoubleQuestionResult?,
      );
    case MultipleChoiceAutoCompleteAnswerFormat:
      return MultipleChoiceAutoCompleteAnswerView(
        key: key,
        questionStep: this,
        result: questionResult as MultipleChoiceQuestionResult?,
      );
    case ImageAnswerFormat:
      return ImageAnswerView(
        key: key,
        questionStep: this,
        result: questionResult as ImageQuestionResult?,
      );
    default:
      throw AnswerFormatNotDefinedException();
  }
}