select method

void select(
  1. int index,
  2. {SelectionEvent event = SelectionEvent.auto}
)

Select (or unselect) item by index If passed event is SelectionEvent.auto function automatically decide that action will need apply

Implementation

void select(int index, {SelectionEvent event = SelectionEvent.auto}) {
  final indexContains = _selectedIndexes.contains(index);
  final computedEvent = event == SelectionEvent.auto
      ? indexContains
          ? SelectionEvent.unselect
          : SelectionEvent.select
      : event;

  if (computedEvent == SelectionEvent.select) {
    if (!indexContains) {
      _selectedIndexes.add(index);
      notifyListeners();
    }
  } else if (computedEvent == SelectionEvent.unselect) {
    if (indexContains) {
      _selectedIndexes.remove(index);
      notifyListeners();
    }
  }
}