items property

set items (List<T> itemList)

Sets the item list, activating the first item, if the previously active item is not in the new list of items.

Note: As itemList is not watched, items must be manually updated on changes.

Implementation

set items(List<T> itemList) {
  if (const ListEquality().equals(itemList, _items)) return;

  _ids.clear();
  var lastActive = activeItem;
  // Ensure [_items] can't change.
  _items = List.unmodifiable(itemList);
  if (lastActive != null) {
    var last = _items.indexOf(lastActive);
    if (last != -1) {
      _activeIndex = last;
      return;
    }
  }
  _activeIndex = activateFirstItemByDefault ? 0 : -1;
  _modelChanged.add(null);
}