run method
List<T>
run({
- required void renderItem(
- FrameContext ctx,
- T item,
- int absoluteIndex,
- bool isFocused,
- bool isSelected,
- KeyBindings? extraBindings,
Runs the prompt with simple item rendering.
renderItem is called for each visible item:
ctx: FrameContext for renderingitem: The item being renderedabsoluteIndex: Index in the full listisFocused: Whether this item is currently focusedisSelected: Whether this item is selected (multi-select)
extraBindings: Additional key bindings to merge (e.g., 'A' for select all).
Returns selected items on confirm, empty list on cancel.
Example:
final selected = prompt.run(
renderItem: (ctx, item, index, focused, selected) {
final arrow = ctx.lb.arrow(focused);
final check = ctx.lb.checkbox(selected);
ctx.highlightedLine('$arrow $check $item', highlighted: focused);
},
);
Implementation
List<T> run({
required void Function(
FrameContext ctx,
T item,
int absoluteIndex,
bool isFocused,
bool isSelected,
) renderItem,
KeyBindings? extraBindings,
}) {
return runCustom(
renderItem: renderItem,
extraBindings: extraBindings,
);
}