multi<T> static method
Creates a multi-select prompt with checkbox UI.
Returns selected items (empty if cancelled).
Implementation
static List<T> multi<T>({
required String title,
required List<T> items,
PromptTheme theme = PromptTheme.dark,
int maxVisible = 12,
Set<int>? initialSelection,
String Function(T)? labelBuilder,
bool withSelectAll = true,
}) {
final prompt = SelectableListPrompt<T>(
title: title,
items: items,
theme: theme,
multiSelect: true,
maxVisible: maxVisible,
initialSelection: initialSelection,
);
KeyBindings? extra;
if (withSelectAll) {
extra = KeyBindings.letter(
char: 'A',
onPress: () => prompt.selection.toggleAll(items.length),
hintDescription: 'select all / clear',
);
}
return prompt.run(
renderItem: (ctx, item, index, focused, selected) {
final label = labelBuilder?.call(item) ?? item.toString();
ctx.checkboxItem(label, focused: focused, checked: selected);
},
extraBindings: extra,
);
}