addOptions method
void
addOptions(
- Map map
)
Implementation
void addOptions(Map<dynamic, dynamic> map){
optionList.clear();
var pollData = map['message']['data'];
var optionsData =pollData['options'];
//timeRemaining.value=pollData['duration'] ;
var durationString = pollData['duration'].toString();
pollId=pollData['id'];
int duration = int.tryParse(durationString) ?? 30; // Default to 30 seconds if parsing fails
timeRemaining.value=duration;
// Iterate over the options dynamically
optionsData.forEach((key, value) {
print('Key: $key, Value: $value');
optionList.add(OptionModel(optionKey: key, optionValue: value));
// You can process the key-value pairs here
// Example: store or display the options
});
}