StreamContextMenuAction<T> class
A single action row in a StreamContextMenu.
StreamContextMenuAction displays a tappable row with an optional leading
widget, a label widget, and an optional trailing widget. It supports
both normal and destructive styles.
The visual appearance adapts to interaction states (hover, pressed, disabled) and can be fully customized via StreamContextMenuActionTheme.
Each action carries a value, and when tapped the default implementation
calls Navigator.pop with that value so the dialog caller can handle it.
Use enabled to control whether the action is interactive (disabled actions
remain visible but are not tappable).
The type parameter T represents the type of value that will be returned
when the action is selected.
A typical use case is to pass a Text as the label. If the text may be
long, set Text.overflow to TextOverflow.ellipsis and Text.maxLines
to 1, as without it the text will wrap to the next line.
{@tool snippet}
Display a normal context menu action:
StreamContextMenuAction(
value: 'reply',
label: Text('Reply'),
leading: Icon(Icons.reply),
)
{@end-tool}
{@tool snippet}
Display a destructive context menu action:
StreamContextMenuAction.destructive(
value: 'block',
label: Text('Block User'),
leading: Icon(Icons.block),
)
{@end-tool}
See also:
- StreamContextMenu, which contains these actions.
- StreamContextMenuSeparator, for visual dividers between actions.
- StreamContextMenuActionTheme, for customizing action appearance.
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- StreamContextMenuAction
Constructors
- StreamContextMenuAction({Key? key, T? value, required Widget label, VoidCallback? onTap, bool enabled = true, Widget? leading, Widget? trailing, bool isDestructive = false})
- Creates a context menu action.
- StreamContextMenuAction.destructive({Key? key, T? value, required Widget label, VoidCallback? onTap, bool enabled = true, Widget? leading, Widget? trailing})
- Creates a destructive context menu action.
Properties
- hashCode → int
-
The hash code for this object.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
finalinherited
-
props
→ StreamContextMenuActionProps<
T> -
The props controlling the appearance and behavior of this action.
final
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
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, int wrapWidth = 65}) → 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
Static Methods
-
partitioned<
T> ({required List< StreamContextMenuAction< items}) → List<T> >Widget> -
Partition
itemsinto non-destructive and destructive groups, then insert a StreamContextMenuSeparator between the two groups. -
sectioned(
{required Iterable< Iterable< sections}) → List<Widget> >Widget> -
Flatten
sectionsinto a single list, inserting a StreamContextMenuSeparator between each non-empty section. -
separated(
{required List< Widget> items}) → List<Widget> -
Add a StreamContextMenuSeparator between each action in the given
items.