'How do I structure inheriting Flutter widgets?

For instance, if I had two types of widget for handling questions that both extend some generic class:

class MultiChoiceQuestion extends GenericQuestion
{ MultiChoiceQuestion(MultiChoiceModel model) : super(model)
}
class UserInputQuestion extends GenericQuestion 
{ UserInputQuestion(UserInputModel model) : super(model)
}
class GenericQuestion extends StatefulWidget {
GenericQuestion(GenericModel)
}

And wanted to pass a list of questions to some parent class LessonWidget:

class LessonWidget extends
StatefulWidget {
  LessonWidget(List<GenericQuestionModel> questions)
}

I run into the issue of not being able to create the question widget in place (as I cannot be sure whether to call to a MultiChoice or UserInput constructor).

I believe this is a fault of my structure. I am trying to implement a form of MVC. How best should this be structured?

i.e What should the LessonWidget build method look like?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source