SelectModel<T> class

A single-select component following the Model architecture.

Displays a list of items and allows the user to select one.

Example

final select = SelectModel<String>(
  title: 'Choose a color:',
  items: ['Red', 'Green', 'Blue'],
);

// In your update function:
switch (msg) {
  case SelectionMadeMsg<String>(:final item):
    print('Selected: $item');
    return (this, Cmd.quit());
  case SelectionCancelledMsg():
    return (this, Cmd.quit());
}
Inheritance

Constructors

SelectModel({required List<T> items, String title = 'Select an option:', bool showTitle = true, bool showHelp = true, bool showPagination = true, int height = 10, int initialIndex = 0, String display(T)?, SelectKeyMap? keyMap, SelectStyles? styles})
Creates a new select model.

Properties

cursor → int
Gets the current cursor position.
no setter
display → String Function(T)?
Custom display function for items.
final
hashCode → int
The hash code for this object.
no setterinherited
items → List<T>
Gets the items.
no setter
keyMap → SelectKeyMap
Key bindings.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectedItem → T?
Gets the currently highlighted item.
no setter
showHelp → bool
Whether to show help text.
final
showPagination → bool
Whether to show pagination.
final
showTitle → bool
Whether to show the title.
final
styles → SelectStyles
Styles.
final
title → String
The title/prompt displayed above the list.
final

Methods

init() → Cmd?
Returns an optional command to execute on program startup.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited
update(Msg msg) → (SelectModel<T>, Cmd?)
Updates the component state in response to a message.
override
view() → String
Renders the current model state for display.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited