select method

void select(
  1. dynamic o
)

Change the option status to be selected. Which option to select can be defined by the index (String) or by the option (T) object itself.

Will clear and select o when mode is SelectionMode.single. When mode is SelectionMode.sameGroup, will clear and select o if the group for this o is not currently selected.

Implementation

void select(dynamic o) {
  assert(o is String || o is T);
  if (o is T) o = indexGetter(o);

  if (mode == SelectionMode.single) {
    _selected = {o};
  } else if (mode == SelectionMode.sameGroup) {
    if (isGroupSelected(_groups[o])) {
      _selected.add(o);
    } else {
      // switch group
      _selected = {o};
    }
  } else {
    _selected.add(o);
  }
}