setItems method

  1. @override
void setItems(
  1. List<DropdownItem<T>> items, {
  2. bool replace = false,
  3. bool rebuild = true,
})
override

Set the given items to the dropdown menu. if replace, the current items will be replaced with the given items, and all history will be cleared. if rebuild, the menu will be rebuilt after the items are set.

ForMultiSelectionDropdownController if replace is true, the previous selected items will be cleared and the new items will be set as selected. if replace is false, the new items's selected status will be ignored.

ForSingleSelectionDropdownController if replace is true, the previous selected item will be cleared and the new item will be set as selected. if replace is false, the new item's selected status will be ignored.

Implementation

@override
void setItems(
  List<DropdownItem<T>> items, {
  bool replace = false,
  bool rebuild = true,
}) {
  if (replace) {
    _selectedItems.clear();
    for (final item in items) {
      if (item.selected) {
        _selectedItems.add(item.value);
      }
    }
  }

  super.setItems(items, replace: replace, rebuild: rebuild);
}