ListModel class

List model for interactive lists.

Features:

  • Item selection with keyboard navigation
  • Optional fuzzy filtering
  • Pagination
  • Loading spinner
  • Status messages
  • Help view

Example:

final list = ListModel(
  items: ['Apple', 'Banana', 'Cherry'].map(StringItem.new).toList(),
  title: 'Fruits',
);
Inheritance

Constructors

ListModel({List<ListItem>? items, ItemDelegate? delegate, int width = 80, int height = 20, String title = 'List', bool showTitle = true, bool showFilter = true, bool showStatusBar = true, bool showPagination = true, bool showHelp = true, bool filteringEnabled = true, bool infiniteScrolling = false, String itemNameSingular = 'item', String itemNamePlural = 'items', ListKeyMap? keyMap, ListStyles? styles, FilterFunc? filter, Duration? statusMessageLifetime})
Creates a new list model.

Properties

cursor int
Gets the cursor position on the current page.
no setter
filteringEnabled bool
Whether filtering is enabled.
getter/setter pair
filterInput TextInputModel
getter/setter pair
filterState FilterState
Gets the current filter state.
no setter
filterValue String
Gets the current filter value.
no setter
globalIndex int
Gets the global index in the unfiltered items.
no setter
hashCode int
The hash code for this object.
no setterinherited
height int
Gets the height.
no setter
help HelpModel
getter/setter pair
index int
Gets the current index in the visible items.
no setter
infiniteScrolling bool
Whether to enable infinite scrolling.
getter/setter pair
isFiltered bool
Whether a filter is applied.
no setter
isShowingSpinner bool
Whether the spinner is currently showing.
no setter
itemNamePlural String
Plural item name for status.
getter/setter pair
itemNameSingular String
Singular item name for status.
getter/setter pair
items List<ListItem>
Gets the items.
getter/setter pair
keyMap ListKeyMap
Key bindings.
getter/setter pair
paginator PaginatorModel
getter/setter pair
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
selectedItem ListItem?
Gets the selected item, or null if none.
no setter
settingFilter bool
Whether currently setting a filter.
no setter
showFilter bool
Whether to show the filter input.
getter/setter pair
showHelp bool
Whether to show help.
getter/setter pair
showPagination bool
Whether to show pagination.
getter/setter pair
showStatusBar bool
Whether to show the status bar.
getter/setter pair
showTitle bool
Whether to show the title.
getter/setter pair
spinner SpinnerModel
getter/setter pair
statusMessage String
Gets the current status message.
no setter
statusMessageLifetime Duration
Status message lifetime.
getter/setter pair
styles ListStyles
List styles.
getter/setter pair
title String
List title.
getter/setter pair
visibleItems List<ListItem>
Gets visible items (filtered or all).
no setter
width int
Gets the width.
no setter

Methods

cursorDown() → void
Move cursor down.
cursorUp() → void
Move cursor up.
disableQuitKeybindings() → void
Disable quit keybindings.
enableQuitKeybindings() → void
Enables quit keybindings.
goToEnd() → void
Go to end.
goToStart() → void
Go to start.
hideStatusMessage() → void
Hide the status message.
init() Cmd?
Returns an optional command to execute on program startup.
override
insertItem(int index, ListItem item) → void
Inserts an item at the given index.
matchesForItem(int index) List<int>?
Gets match indices for an item (for highlighting).
newStatusMessage(String message) Cmd?
Set a status message.
nextPage() → void
Go to next page.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
prevPage() → void
Go to previous page.
removeItem(int index) → void
Removes an item at the given index.
resetFilter() → void
Reset the filter.
resetSelected() → void
Reset selection to start.
select(int index) → void
Select item at index.
setFilteringEnabled(bool enabled) → void
Sets whether filtering is enabled.
setHeight(int height) → void
Sets the height.
setItem(int index, ListItem item) → void
Sets an item at the given index.
setItems(List<ListItem> items) → void
Sets the items (parity with bubbles).
setShowFilter(bool show) → void
Sets whether to show the filter.
setShowHelp(bool show) → void
Sets whether to show help.
setShowPagination(bool show) → void
Sets whether to show pagination.
setShowStatusBar(bool show) → void
Sets whether to show the status bar.
setShowTitle(bool show) → void
Sets whether to show the title.
setSize(int width, int height) → void
Sets the size.
setSpinner(Spinner s) → void
Sets the spinner animation.
setWidth(int width) → void
Sets the width.
startSpinner() Cmd?
Starts the spinner.
stopSpinner() → void
Stops the spinner.
toggleSpinner() Cmd?
Toggles the spinner.
toString() String
A string representation of this object.
inherited
update(Msg msg) → (ListModel, Cmd?)
Updates the component state in response to a message.
override
updateKeybindings() → void
Update keybindings based on state.
view() String
Renders the current model state for display.
override

Operators

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