CallbackShortcuts class Null safety

A widget that provides an uncomplicated mechanism for binding a key combination to a specific callback.

This is similar to the functionality provided by the Shortcuts widget, but instead of requiring a mapping to an Intent, and an Actions widget somewhere in the widget tree to bind the Intent to, it just takes a set of bindings that bind the key combination directly to a VoidCallback.

Because it is a simpler mechanism, it doesn't provide the ability to disable the callbacks, or to separate the definition of the shortcuts from the definition of the code that is triggered by them (the role that actions play in the Shortcuts/Actions system).

However, for some applications the complexity and flexibility of the Shortcuts and Actions mechanism is overkill, and this widget is here for those apps.

Shortcuts and CallbackShortcuts can both be used in the same app. As with any key handling widget, if this widget handles a key event then widgets above it in the focus chain will not receive the event. This means that if this widget handles a key, then an ancestor Shortcuts widget (or any other key handling widget) will not receive that key, and similarly, if a descendant of this widget handles the key, then the key event will not reach this widget for handling.

See also:

  • Focus, a widget that defines which widgets can receive keyboard focus.
Inheritance

Constructors

CallbackShortcuts({Key? key, required Map<ShortcutActivator, VoidCallback> bindings, required Widget child})
Creates a const CallbackShortcuts widget.
const

Properties

bindings Map<ShortcutActivator, VoidCallback>
A map of key combinations to callbacks used to define the shortcut bindings.
final
child Widget
The widget below this widget in the tree.
final
hashCode int
The hash code for this object.
nonVirtual">@nonVirtualread-onlyinherited
key Key?
Controls how one widget replaces another widget in the tree.
finalinherited
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited

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.
protected">@protectedinherited
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
inherited
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent 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.
nonVirtual">@nonVirtualinherited