setItems method
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
void setItems(
List<DropdownItem<T>> items, {
bool replace = false,
bool rebuild = true,
}) {
if (!replace) {
_itemValues.addAll(items.map((e) => e.value));
} else {
_clearHistory();
_itemValues = items.map((e) => e.value).toSet();
}
if (rebuild) {
rebuildMenu();
}
}