ShortcutSerialization.modifier constructor

ShortcutSerialization.modifier(
  1. LogicalKeyboardKey trigger, {
  2. bool alt = false,
  3. bool control = false,
  4. bool meta = false,
  5. bool shift = false,
})

Creates a ShortcutSerialization representing a specific LogicalKeyboardKey and modifiers.

This is used by a SingleActivator to serialize itself.

Implementation

ShortcutSerialization.modifier(
  LogicalKeyboardKey trigger, {
  bool alt = false,
  bool control = false,
  bool meta = false,
  bool shift = false,
})  : assert(trigger != LogicalKeyboardKey.alt &&
             trigger != LogicalKeyboardKey.altLeft &&
             trigger != LogicalKeyboardKey.altRight &&
             trigger != LogicalKeyboardKey.control &&
             trigger != LogicalKeyboardKey.controlLeft &&
             trigger != LogicalKeyboardKey.controlRight &&
             trigger != LogicalKeyboardKey.meta &&
             trigger != LogicalKeyboardKey.metaLeft &&
             trigger != LogicalKeyboardKey.metaRight &&
             trigger != LogicalKeyboardKey.shift &&
             trigger != LogicalKeyboardKey.shiftLeft &&
             trigger != LogicalKeyboardKey.shiftRight,
             'Specifying a modifier key as a trigger is not allowed. '
             'Use provided boolean parameters instead.'),
      _trigger = trigger,
      _character = null,
      _alt = alt,
      _control = control,
      _meta = meta,
      _shift = shift,
      _internal = <String, Object?>{
        _kShortcutTrigger: trigger.keyId,
        _kShortcutModifiers: (alt ? _shortcutModifierAlt : 0) |
          (control ? _shortcutModifierControl : 0) |
          (meta ? _shortcutModifierMeta : 0) |
          (shift ? _shortcutModifierShift : 0),
      };