constrainTo method

void constrainTo(
  1. int itemCount
)

Constrains selection to valid indices for the given item count.

Removes any indices that are >= itemCount. Call this when the underlying list changes size.

Implementation

void constrainTo(int itemCount) {
  _selected.removeWhere((i) => i >= itemCount);
}