multiSelect<T> function

List<T> multiSelect<T>(
  1. String message, {
  2. required List<T> options,
  3. required String display(
    1. T
    ),
})

Prompts the user to select multiple options from a list.

Implementation

List<T> multiSelect<T>(
  String message, {
  required List<T> options,
  required String Function(T) display,
}) {
  final selection = MultiSelect.withTheme(
    prompt:
        '$message ${Logger.mutedPen.write('(↑↓ navigate, space to select)')}',
    options: List.of(options.map(display)),
    theme: checkboxTheme,
  ).interact();
  return List.of(selection.map((index) => options[index]));
}