selectItem method
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();
}