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.


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


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


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


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