select method
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();
}
final selected = _selectedItems.contains(value);
if (selected) {
if (_unselectable) {
_selectedItems.remove(value);
}
} else if (value != null) {
_selectedItems.add(value);
}
if (refresh) {
notifyListeners();
rebuildMenu();
}
}