generateAnswerBody static method
Implementation
static String generateAnswerBody(
List<AskUserChoice> options,
String? answer,
) {
if (options.isNotEmpty) {
List<int> indices = options.asMap().keys.toList();
List<String> values = options.map((option) => option.choice).toList();
return jsonEncode({
"choice": {"index": indices, "value": values},
});
} else if (answer != null) {
return jsonEncode({
"choice": {"value": answer},
});
} else {
return jsonEncode({"choice": {}});
}
}