SearchModel<T> constructor

SearchModel<T>({
  1. required List<T> items,
  2. String title = '',
  3. String placeholder = 'Type to search...',
  4. String noResultsText = 'No matches found',
  5. bool showTitle = true,
  6. bool showHelp = true,
  7. bool showPagination = true,
  8. bool highlightMatches = true,
  9. int height = 10,
  10. int initialIndex = 0,
  11. String display(
    1. T
    )?,
  12. SearchFilterFunc<T>? filter,
  13. SearchKeyMap? keyMap,
  14. 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();
}