selectItem method

void selectItem(
  1. int index
)

Selects the item at the specified index and closes the menu.

Implementation

void selectItem(int index) {
  if (index >= 0 && index < widget.items.length) {
    final selectedValue = widget.items[index].value;
    widget.onChanged?.call(selectedValue);
  }
  closeDropdown();
}