Survey.fromMap constructor

Survey.fromMap(
  1. Map<String, dynamic> map
)

Implementation

factory Survey.fromMap(Map<String, dynamic> map) {
  final List<ChoiceItem> choices = [];
  if (map.containsKey('options')) {
    final choiceMap = map['options'] as Map<String, dynamic>;
    choiceMap.forEach(
      (key, value) => choices.add(ChoiceItem(id: key, text: value)),
    );
  }
  return Survey(
    question: map['question'] ?? '',
    choices: choices,
  );
}