toggle method

bool toggle(
  1. int index
)

Toggles selection for index. Returns the new selected state.

Implementation

bool toggle(int index) {
  final bool nowSelected;
  if (_selected.contains(index)) {
    _selected.remove(index);
    nowSelected = false;
  } else {
    _selected.add(index);
    nowSelected = true;
  }
  notifyListeners();
  return nowSelected;
}