itemCount property

int get itemCount

Total number of items.

Implementation

int get itemCount => _itemCount;
set itemCount (int value)

Updates the total item count (e.g., when filtering changes the list).

Automatically clamps selection to valid range and adjusts scroll.

Implementation

set itemCount(int value) {
  _itemCount = max(0, value);
  if (_itemCount == 0) {
    _selectedIndex = 0;
    _scrollOffset = 0;
  } else {
    _selectedIndex = _selectedIndex.clamp(0, _itemCount - 1);
    _adjustScroll();
  }
}