run method

List<T> run({
  1. required void renderItem(
    1. FrameContext ctx,
    2. T item,
    3. int absoluteIndex,
    4. bool isFocused,
    5. bool isSelected,
    ),
  2. KeyBindings? extraBindings,
})

Runs the prompt with simple item rendering.

renderItem is called for each visible item:

  • ctx: FrameContext for rendering
  • item: The item being rendered
  • absoluteIndex: Index in the full list
  • isFocused: Whether this item is currently focused
  • isSelected: 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,
  );
}