CharacterActivator class Null safety

A shortcut combination that is triggered by a key event that produces a specific character.

Keys often produce different characters when combined with modifiers. For example, it might be helpful for the user to bring up a help menu by pressing the question mark ('?'). However, there is no logical key that directly represents a question mark. Although 'Shift+Slash' produces a '?' character on a US keyboard, its logical key is still considered a Slash key, and hard-coding 'Shift+Slash' in this situation is unfriendly to other keyboard layouts.

For example, CharacterActivator('?') is triggered when a key combination results in a question mark, which is 'Shift+Slash' on a US keyboard, but 'Shift+Comma' on a French keyboard.

In the following example, when a key combination results in a question mark, the counter is increased:
To create a local project with this code sample, run:
flutter create --sample=widgets.CharacterActivator.1 mysample

See also:

  • SingleActivator, an activator that represents a single key combined with modifiers, such as Ctrl+C.
Implemented types
Mixed in types

Constructors

CharacterActivator(String character, {bool control = false, bool meta = false, bool includeRepeats = true})
Triggered when the key event yields the given character.
const

Properties

character String
The character of the triggering event.
final
control bool
Whether either (or both) control keys should be held for the character to activate the shortcut.
final
hashCode int
The hash code for this object.
read-onlyinherited
includeRepeats bool
Whether this activator accepts repeat events of the character.
final
meta bool
Whether either (or both) meta keys should be held for the character to activate the shortcut.
final
runtimeType Type
A representation of the runtime type of the object.
read-onlyinherited
triggers Iterable<LogicalKeyboardKey>?
All the keys that might be the final event to trigger this shortcut.
read-onlyoverride

Methods

accepts(RawKeyEvent event, RawKeyboard state) bool
Whether the triggering event and the keyboard state at the time of the event meet required conditions, providing that the event is a triggering event.
override
debugDescribeKeys() String
Returns a description of the key set that is short and readable.
override
debugFillProperties(DiagnosticPropertiesBuilder properties) → void
Add additional properties associated with the node.
override
noSuchMethod(Invocation invocation) → dynamic
Invoked when a non-existent method or property is accessed.
inherited
serializeForMenu() ShortcutSerialization
Implement this in a ShortcutActivator subclass to allow it to be serialized for use in a PlatformMenuBar.
override
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
toStringShort() String
A brief description of this object, usually just the runtimeType and the hashCode.
inherited

Operators

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