CheckboxMenuButton class

A menu item that combines a Checkbox widget with a MenuItemButton.

To style the checkbox separately from the button, add a CheckboxTheme ancestor.

This example shows a menu with a checkbox that shows a message in the body of the app if checked.
link

To create a local project with this code sample, run:
flutter create --sample=material.CheckboxMenuButton.1 mysample

See also:

  • MenuBar, a widget that creates a menu bar of cascading menu items.
  • MenuAnchor, a widget that defines a region which can host a cascading menu.
Inheritance

Constructors

CheckboxMenuButton({Key? key, required bool? value, bool tristate = false, bool isError = false, required ValueChanged<bool?>? onChanged, ValueChanged<bool>? onHover, ValueChanged<bool>? onFocusChange, FocusNode? focusNode, MenuSerializableShortcut? shortcut, ButtonStyle? style, MaterialStatesController? statesController, Clip clipBehavior = Clip.none, Widget? trailingIcon, bool closeOnActivate = true, required Widget? child})
Creates a const CheckboxMenuButton.
const

Properties

child Widget?
The widget displayed in the center of this button.
final
clipBehavior Clip
The content will be clipped (or not) according to this option.
final
closeOnActivate bool
Determines if the menu will be closed when a MenuItemButton is pressed.
final
enabled bool
Whether the button is enabled or disabled.
no setter
focusNode FocusNode?
An optional focus node to use as the focus node for this widget.
final
hashCode int
The hash code for this object.
no setterinherited
isError bool
True if this checkbox wants to show an error state.
final
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
onChanged ValueChanged<bool?>?
Called when the value of the checkbox should change.
final
onFocusChange ValueChanged<bool>?
Handler called when the focus changes.
final
onHover ValueChanged<bool>?
Called when a pointer enters or exits the button response area.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
shortcut MenuSerializableShortcut?
The optional shortcut that selects this MenuItemButton.
final
statesController MaterialStatesController?
Represents the interactive "state" of this widget in terms of a set of MaterialStates, like MaterialState.pressed and MaterialState.focused.
final
style ButtonStyle?
Customizes this button's appearance.
final
trailingIcon Widget?
An optional icon to display after the child label.
final
tristate bool
If true, then the checkbox's value can be true, false, or null.
final
value bool?
Whether this checkbox is checked.
final

Methods

build(BuildContext context) Widget
Describes the part of the user interface represented by this widget.
override
createElement() StatelessElement
Creates a StatelessElement to manage this widget's location in the tree.
inherited
debugDescribeChildren() List<DiagnosticsNode>
Returns a list of DiagnosticsNode objects describing this node's children.
inherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
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
toStringDeep({String prefixLineOne = '', String? prefixOtherLines, DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a string representation of this node and its descendants.
inherited
toStringShallow({String joiner = ', ', DiagnosticLevel minLevel = DiagnosticLevel.debug}) String
Returns a one-line detailed description of the object.
inherited
toStringShort() String
A short, textual description of this widget.
inherited

Operators

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