SelectableMenuItem<ItemType> constructor
SelectableMenuItem<ItemType> ({
- required ItemType value,
- ItemRenderer<
ItemType> itemRenderer = defaultItemRenderer, - Icon? icon,
- MenuModel? subMenu,
- String tooltip = '',
- String secondaryLabel = '',
- String labelAnnotation = '',
- Iterable<
String> ? cssClasses, - MenuAction? action,
- ActionWithContext? actionWithContext,
- SelectableOption selectableState = SelectableOption.Selectable,
- bool? shouldSelectOnItemClick,
- MenuItemAffix? itemSuffix,
- ObservableList<
MenuItemAffix> ? itemSuffixes,
The constructor for a selectable MenuItem.
Selectable menu items can be managed with a SelectionModel from within MenuItemGroupWithSelection. Selected menu items are marked in the UI and can change the selection via user interactions.
itemSuffixes
- the list of suffixes rendered after the item content.
itemSuffix
- singular item suffix to be rendered after the item content;
convenient way to pass a single item suffix in rather than
constructing an ObservableList and using itemSuffixes
. If
itemSuffixes
is also passed in, itemSuffixes
takes precedence.
Implementation
SelectableMenuItem(
{required this.value,
this.itemRenderer = defaultItemRenderer,
Icon? icon,
MenuModel? subMenu,
this.tooltip = '',
this.secondaryLabel = '',
this.labelAnnotation = '',
Iterable<String>? cssClasses,
MenuAction? action,
ActionWithContext? actionWithContext,
SelectableOption selectableState = SelectableOption.Selectable,
bool? shouldSelectOnItemClick,
MenuItemAffix? itemSuffix,
ObservableList<MenuItemAffix>? itemSuffixes})
: _selectableState = selectableState,
this.subMenu = subMenu ?? MenuModel([]),
this.icon = icon ?? Icon.blank(),
shouldSelectOnItemClick = shouldSelectOnItemClick ?? subMenu == null,
itemSuffixes = itemSuffixes ??
ObservableList<MenuItemAffix>.from(
Optional.fromNullable(itemSuffix)),
cssClasses = BuiltList<String>((cssClasses ?? const <String>[])) {
assert(itemSuffix == null || itemSuffixes == null,
'Only one of itemSuffix or itemSuffixes should be provided');
assert(action == null || actionWithContext == null,
'Only one of action or actionWithContext should be provided');
if (action != null) {
_action = action;
_actionWithContext = (_) => action();
} else if (actionWithContext != null) {
_action = () => actionWithContext(null);
_actionWithContext = actionWithContext;
} else {
_action = _noOp;
_actionWithContext = _noOp2;
}
}