PlatformProvidedMenuItem class Null safety

A class that represents a menu item that is provided by the platform.

This is used to add things like the "About" and "Quit" menu items to a platform menu.

The type enum determines which type of platform defined menu will be added.

This is most useful on a macOS platform where there are many different types of platform provided menu items in the standard menu setup.

In order to know if a PlatformProvidedMenuItem is available on a particular platform, call PlatformProvidedMenuItem.hasMenu.

If the platform does not support the given type, then the menu item will throw an ArgumentError when it is sent to the platform.

See also:

  • PlatformMenuBar which takes these items for inclusion in a platform-rendered menu bar.
Inheritance

Constructors

PlatformProvidedMenuItem({required PlatformProvidedMenuItemType type, bool enabled = true})
Creates a const PlatformProvidedMenuItem of the appropriate type. Throws if the platform doesn't support the given default menu type.
const

Properties

descendants List<MenuItem>
Returns all descendant MenuItems of this item.
read-only, inherited
enabled bool
True if this PlatformProvidedMenuItem should be enabled or not.
final
hashCode int
The hash code for this object.
read-only, inherited
label String
The required label used for rendering the menu item.
final, inherited
members List<MenuItem>
Returns the list of group members if this menu item is a "grouping" menu item, such as PlatformMenuItemGroup.
read-only, inherited
Returns any child MenuItems of this item.
read-only, inherited
onClose VoidCallback?
Returns a callback, if any, to be invoked if the platform menu receives a "Menu.closed" method call from the platform for this item.
read-only, inherited
onOpen VoidCallback?
Returns a callback, if any, to be invoked if the platform menu receives a "Menu.opened" method call from the platform for this item.
read-only, inherited
onSelected VoidCallback?
An optional callback that is called when this PlatformMenuItem is selected.
final, inherited
onSelectedIntent Intent?
An optional intent that is invoked when this PlatformMenuItem is selected.
final, inherited
runtimeType Type
A representation of the runtime type of the object.
read-only, inherited
shortcut MenuSerializableShortcut?
The optional shortcut that selects this PlatformMenuItem.
final, inherited
type PlatformProvidedMenuItemType
The type of default menu this is.
final

Methods

debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
toChannelRepresentation(PlatformMenuDelegate delegate, {required MenuItemSerializableIdGenerator getId}) Iterable<Map<String, Object?>>
Converts the representation of this item into a map suitable for sending over the default "flutter/menu" channel used by DefaultPlatformMenuDelegate.
override
toDiagnosticsNode({String? name, DiagnosticsTreeStyle? style}) DiagnosticsNode
Returns a debug representation of the object that is used by debugging tools and by DiagnosticsNode.toStringDeep.
inherited
toString({DiagnosticLevel minLevel = DiagnosticLevel.info}) String
A string representation of this object.
inherited
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.
inherited

Operators

operator ==(Object other) bool
The equality operator.
inherited

Static Methods

hasMenu(PlatformProvidedMenuItemType menu) bool
Checks to see if the given default menu type is supported on this platform.