MenuItem<T> constructor
- String label, {
- bool enabled = true,
- String tooltip = '',
- ActionWithContext? actionWithContext,
- Icon? icon,
- String labelAnnotation = '',
- Iterable<
String> ? cssClasses, - MenuItemAffix? itemSuffix,
- ObservableList<
MenuItemAffix> ? itemSuffixes, - MenuModel<
T> ? subMenu, - String secondaryLabel = '',
- String? ariaLabel,
The constructor for a MenuItem which displays label
.
By default this MenuItem is enabled
, otherwise it will be faded.
If tooltip
is passed, the text is shown when this item is hovered.
If action
is passed, it is called when the item is triggered.
If icon
is passed, it is shown to the left of the label
.
If secondaryIcon
is passed, it is shown to the right of label
;
its visibility is defined by secondaryIconVisibility
.
If subMenu
is passed, this item will display an arrow to the right of
label
, and when this item is triggered it will open subMenu
.
If itemSuffixes
is passed, the list of suffixes will be 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
MenuItem(this.label,
{this.enabled = true,
this.tooltip = '',
//@Deprecated('Use ActionWithContext') MenuAction? action,
this.actionWithContext,
this.icon,
this.labelAnnotation = '',
Iterable<String>? cssClasses,
MenuItemAffix? itemSuffix,
ObservableList<MenuItemAffix>? itemSuffixes,
MenuModel<T>? subMenu,
this.secondaryLabel = '',
String? ariaLabel})
: itemSuffixes = itemSuffixes ??
ObservableList<MenuItemAffix>.from(
Optional.fromNullable(itemSuffix)),
cssClasses = BuiltList<String>((cssClasses ?? const <String>[])),
this.subMenu = subMenu ?? MenuModel([]),
ariaLabel = ariaLabel ?? label {
assert(itemSuffix == null || itemSuffixes == null,
'Only one of itemSuffix or itemSuffixes should be provided');
}