ShortcutSerialization.modifier constructor Null safety

ShortcutSerialization.modifier(
  1. LogicalKeyboardKey trigger,
  2. {bool control = false,
  3. bool shift = false,
  4. bool alt = false,
  5. bool meta = 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 control = false,
  bool shift = false,
  bool alt = false,
  bool meta = false,
})  : assert(trigger != LogicalKeyboardKey.shift &&
             trigger != LogicalKeyboardKey.shiftLeft &&
             trigger != LogicalKeyboardKey.shiftRight &&
             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,
             'Specifying a modifier key as a trigger is not allowed. '
             'Use provided boolean parameters instead.'),
      _trigger = trigger,
      _control = control,
      _shift = shift,
      _alt = alt,
      _meta = meta,
      _internal = <String, Object?>{
        _kShortcutTrigger: trigger.keyId,
        _kShortcutModifiers: (control ? _shortcutModifierControl : 0) |
            (alt ? _shortcutModifierAlt : 0) |
            (shift ? _shortcutModifierShift : 0) |
            (meta ? _shortcutModifierMeta : 0),
      };