selectItem method

void selectItem(
  1. int index
)

Selects the item at the specified index if enabled, and closes the menu.

Implementation

void selectItem(int index) {
  if (index >= 0 && index < widget.items.length) {
    final item = widget.items[index];
    if (item.enabled) {
      widget.onSelected?.call(item.value);
    }
  }
  closeMenu();
}