setItems method
void
setItems(
- List<
DropdownItem< items, {T> > - bool replace = false,
- 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) {
_selectedItemValue = null;
for (final item in items) {
if (item.selected) {
assert(_selectedItemValue == null,
"Only one item can be selected at a time");
_selectedItemValue = item.value;
}
}
}
super.setItems(items, replace: replace, rebuild: rebuild);
}