addQuestion method
void
addQuestion(
- dynamic pQuestion,
- dynamic key, {
- dynamic isBoolean = false,
- dynamic isList = false,
- dynamic isMessage = false,
This method is another way of adding questions after instantiating CLI_Dialog
Pass is_bool
or isList
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'], isList: true);
Implementation
void addQuestion(pQuestion, key,
{isBoolean = false, isList = false, isMessage = false}) {
if ((isBoolean ? 1 : 0) + (isList ? 1 : 0) + (isMessage ? 1 : 0) > 1) {
throw ArgumentError(
'A question can not have more than one boolean qualifier.');
}
final newItem = [pQuestion, key];
if (isBoolean) {
booleanQuestions!.add(newItem);
} else if (isList) {
listQuestions!.add(newItem);
} else if (isMessage) {
messages!.add(newItem);
} else {
questions!.add(newItem);
}
}