MenuItem<T> constructor

MenuItem<T>(
  1. String label, {
  2. bool enabled = true,
  3. String tooltip = '',
  4. ActionWithContext? actionWithContext,
  5. Icon? icon,
  6. String labelAnnotation = '',
  7. Iterable<String>? cssClasses,
  8. MenuItemAffix? itemSuffix,
  9. ObservableList<MenuItemAffix>? itemSuffixes,
  10. MenuModel<T>? subMenu,
  11. String secondaryLabel = '',
  12. 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');
}