chooseAny<T> method

Future<List<T>> chooseAny<T>(
  1. String question, {
  2. required List<T> choices,
  3. List<T>? defaultValues,
  4. String display(
    1. T choice
    )?,
  5. bool? filter,
  6. int min = 0,
  7. int? max,
})

Asks question for any of choices, which must not be empty, answered in the order of choices: at least min of them, at most max (no limit when null); a choice of fewer or more is refused with a message and asked again.

It asks as chooseOne does, Space toggling the choice the cursor is on, those of defaultValues toggled at first; in the plain mode the numbers are separated by commas or blanks (1,3), and an empty answer is defaultValues. Once answered they are shown joined by commas. Where nobody can answer, a prompt without defaultValues, or with fewer or more of them than min and max allow, throws PromptAnswerRequiredException.

final features = await Cli.current.chooseAny(
  'Features?',
  choices: ['Linter', 'Docker', 'Tests'],
  defaultValues: ['Linter'],
);

Implementation

Future<List<T>> chooseAny<T>(
  String question, {
  required List<T> choices,
  List<T>? defaultValues,
  String Function(T choice)? display,
  bool? filter,
  int min = 0,
  int? max,
}) => _prompter.chooseAny(
  question,
  choices: choices,
  defaultValues: defaultValues,
  display: display,
  filter: filter,
  min: min,
  max: max,
);