toMap method

Map<String, dynamic> toMap()

This method returns a Map<String,String> object of the current state of the question cards. This format is useful for writing to a database eg Firestore.

Implementation

Map<String, dynamic> toMap() {
  Map<String, dynamic> temp = new Map<String, dynamic>();
  expanded.forEach((element) {
    String? answer = (!(element.keys.toList()[0] is NestedQuestion ||
            element.keys.toList()[0] is PolarQuestion))
        ? element.keys.toList()[0].answer.text
        : element[element.keys.toList()[0]];
    temp[element.keys.toList()[0].toString()] = answer;
  });
  return temp;
}