ActionsModifier class

A widget that establishes an ActionDispatcher and a map of Intent to Action to be used by its descendants when invoking an Action.

Actions are typically invoked using Actions.invoke with the context containing the ambient Actions widget.

{@tool dartpad} This example creates a custom Action subclass ModifyAction for modifying a model, and another, SaveAction for saving it.

This example demonstrates passing arguments to the Intent to be carried to the Action. Actions can get data either from their own construction (like the model in this example), or from the intent passed to them when invoked (like the increment amount in this example).

This example also demonstrates how to use Intents to limit a widget's dependencies on its surroundings. The SaveButton widget defined in this example can invoke actions defined in its ancestor widgets, which can be customized to match the part of the widget tree that it is in. It doesn't need to know about the SaveAction class, only the SaveIntent, and it only needs to know about a value notifier, not the entire model.

** See code in examples/api/lib/widgets/actions/actions.0.dart ** {@end-tool}

See also:

  • ActionDispatcher, the object that this widget uses to manage actions.
  • Action, a class for containing and defining an invocation of a user action.
  • Intent, a class that holds a unique LocalKey identifying an action, as well as configuration information for running the Action.
  • Shortcuts, a widget used to bind key combinations to Intents.
Inheritance
Available extensions

Constructors

ActionsModifier({Key? key, Key? modifierKey, Widget? child, ActionDispatcher? dispatcher, required Map<Type, Action<Intent>> actions})
Creates an Actions widget.
const

Properties

actions Map<Type, Action<Intent>>
A map of Intent keys to Action<Intent> objects that defines which actions this widget knows about.
final
dispatcher ActionDispatcher?
The ActionDispatcher object that invokes actions.
final
hashCode int
The hash code for this object.
no setterinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
modifierKey Key?
The actual key of the widget, which Modifier wrapped
finalinherited
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.
inherited
buildWithChild(BuildContext context, Widget? child) Widget
A build method that receives an extra child parameter.
override
createElement() SingleChildStatelessElement
Create a SingleChildStatelessElement
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