SearchModel<T> class

A search/filter component following the Model architecture.

Combines a text input with a filterable list of items.

Example

final search = SearchModel<String>(
  title: 'Search files:',
  items: ['main.dart', 'pubspec.yaml', 'README.md'],
);

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

Constructors

SearchModel({required List<T> items, String title = '', String placeholder = 'Type to search...', String noResultsText = 'No matches found', bool showTitle = true, bool showHelp = true, bool showPagination = true, bool highlightMatches = true, int height = 10, int initialIndex = 0, String display(T)?, SearchFilterFunc<T>? filter, SearchKeyMap? keyMap, SearchStyles? styles})
Creates a new search model.

Properties

cursor → int
Gets the current cursor position.
no setter
display → String Function(T)?
Custom display function for items.
final
filteredItems → List<FilteredSearchItem<T>>
Gets the filtered items.
no setter
hashCode → int
The hash code for this object.
no setterinherited
highlightMatches → bool
Whether to highlight matched characters.
final
items → List<T>
Gets the items.
no setter
keyMap → SearchKeyMap
Key bindings.
final
noResultsText → String
Text shown when no results match.
final
placeholder → String
Placeholder text for the search input.
final
query → String
Gets the current search query.
no setter
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
selectedItem → FilteredSearchItem<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 → SearchStyles
Styles.
final
title → String
The title displayed above the search.
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) → (SearchModel<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