CallbackShortcuts class
A widget that binds key combinations to specific callbacks.
This is similar to but simpler than the Shortcuts widget as it doesn't require Intents and Actions widgets. Instead, it accepts a map of ShortcutActivators to VoidCallbacks.
Unlike Shortcuts, this widget does not separate key bindings and their implementations. This separation allows Shortcuts to have key bindings that adapt to the focused context. For example, the desired action for a deletion intent may be to delete a character in a text input, or to delete a file in a file menu.
To create a local project with this code sample, run:
flutter create --sample=widgets.CallbackShortcuts.1 mysample
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. Similarly, if a descendant of this widget handles the key, then the key event will not reach this widget for handling.
See the article on Using Actions and Shortcuts for a detailed explanation.
See also:
- Inheritance
-
- Object
- DiagnosticableTree
- Widget
- StatelessWidget
- CallbackShortcuts
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.
no setterinherited
- key → Key?
-
Controls how one widget replaces another widget in the tree.
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.
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