select method

  1. @override
void select(
  1. T? value, {
  2. bool dismiss = true,
  3. bool refresh = true,
})
override

Select the given value. if dismiss, the menu will be dismissed no matter the value is selected or not. if refresh, the menu will be rebuilt after the value is selected.

if value is null or duplicated, it may unselect it if _unselectable is true.

Implementation

@override
void select(
  T? value, {
  bool dismiss = true,
  bool refresh = true,
}) {
  if (dismiss) {
    this.dismiss();
  }

  if (value == null || value == _selectedItemValue) {
    if (_unselectable) {
      _selectedItemValue = null;
    }
  } else {
    _selectedItemValue = value;
  }

  if (refresh) {
    notifyListeners();
    rebuildMenu();
  }
}