addItem method

void addItem(
  1. DropdownItem<T> option, {
  2. int index = -1,
})

Adds a dropdown item to the list of dropdown items. The index parameter is optional, and if provided, the item will be inserted at the specified index.

Implementation

void addItem(DropdownItem<T> option, {int index = -1}) {
  if (index == -1) {
    _items.add(option);
  } else {
    _items.insert(index, option);
  }
  notifyListeners();
  _onSelectionChanged?.call(_selectedValues);
}