question_asker_bm 0.0.2 question_asker_bm: ^0.0.2 copied to clipboard
A Library to create a multiple choice and yes/no type questions CLI Wizard in dart
question_asker_bm #
This library can be used to create a multiple choice and yes/no type question wizard CLI in dart
Usage #
Import the package #
To use this library, follow the library installation instructions.
Use the Library #
Add the following import to your Dart code:
import 'package:question_asker_bm/question_asker_bm.dart';
Instantiate Asker
class with the scopes you want:
final asker = new Asker();
List of Methods you can use: #
1. askMultiple(question,options)
a) First argument is the question to ask
b) Second argument is the list of answers(options) for the given question
*Note*: This function returns the option selected by the user
2. askBinary(question)
=> Takes an argument as the question to ask
*Note*: This function return either TRUE or FALSE based on the value selected by the user.
a) This returns true if user type y or yes
b) This returns flase if user type f or false
You can now use the Asker
class to use the methods in your Dart code, e.g.
void main()
{
//craete a list of Options for a given question
final options = [new Option('I like Green', '#00ff00'),
new Option('I like White', '#FFFFFF')];
//creating the object of Asker class
final asker = new Asker();
//Asking a multiple choice quesition along with passing the options for the question
String choosenAns = asker.askMultiple('What color do you like?', options);
//asking a binary type means Yes or No type Question
bool ansBinary = asker.askBinary('Do you like This Lib?');
//displaying the result choosen by the user
print(choosenAns); //#00ff00 or #FFFFFF
print(ansBinary); //true or false
}