SearchModel<T> constructor
SearchModel<T> ({
- 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.
Implementation
SearchModel({
required List<T> items,
this.title = '',
this.placeholder = 'Type to search...',
this.noResultsText = 'No matches found',
this.showTitle = true,
this.showHelp = true,
this.showPagination = true,
this.highlightMatches = true,
int height = 10,
int initialIndex = 0,
this.display,
SearchFilterFunc<T>? filter,
SearchKeyMap? keyMap,
SearchStyles? styles,
}) : _items = items,
_filter = filter ?? defaultSearchFilter,
keyMap = keyMap ?? SearchKeyMap(),
styles = styles ?? SearchStyles.defaults(),
_height = height {
_input = TextInputModel(prompt: '🔍 ', placeholder: placeholder);
_paginator = PaginatorModel(
type: PaginationType.dots,
activeDot: '●',
inactiveDot: '○',
);
_runFilter();
_cursor = initialIndex.clamp(
0,
_filteredItems.isEmpty ? 0 : _filteredItems.length - 1,
);
_updatePagination();
}