addQuestion method
void
addQuestion(
- dynamic p_question,
- dynamic key, {
- dynamic is_boolean = false,
- dynamic is_list = false,
- dynamic is_message = false,
This method is another way of adding questions after instantiating CLI_Dialog
Pass is_bool
or is_list
as a named argument to indicate the type of question you are adding (boolean qualifier).
final dialog = CLI_Dialog();
dialog.addQuestion([{'question': 'How are you?', options: ['Good', 'Not so good']}, 'mood'], is_list: true);
Implementation
void addQuestion(p_question, key,
{is_boolean = false, is_list = false, is_message = false}) {
if ((is_boolean ? 1 : 0) + (is_list ? 1 : 0) + (is_message ? 1 : 0) > 1) {
throw ArgumentError(
'A question can not have more than one boolean qualifier.');
}
final newItem = [p_question, key];
if (is_boolean) {
booleanQuestions!.add(newItem);
} else if (is_list) {
listQuestions!.add(newItem);
} else if (is_message) {
messages!.add(newItem);
} else {
questions!.add(newItem);
}
}