setState method

void setState(
  1. Map<String, dynamic> doc
)

This method is used to set the state of the cards containing the questions and answers.

It accepts a parameter doc of type Map<String,String> which essentially contains an unordered list of question:answer key:value pairs typically fetched from a database. This method sets the state and arranges the questions according to the order specified by the _questionStructure variable.

Implementation

void setState(Map<String, dynamic> doc) {
  this.resetState();
  for (int i = 0; i < expanded.length; i++) {
    doc.keys.forEach((field) {
      if (expanded[i].keys.toList()[0].toString() == field) {
        if (!(expanded[i].keys.toList()[0] is NestedQuestion ||
            expanded[i].keys.toList()[0] is PolarQuestion))
          expanded[i].keys.toList()[0].answer.text = doc[field];

        this._onEvent(expanded[i], doc[field]);
      }
    });
  }
}