import 'package:flutter/foundation.dart'; import 'package:flutter/services.dart'; /// The step Alt+` (1) or Alt+Shift+` (-1) moves between the app's floating /// windows, or null for any other key. A browser keeps Ctrl+Tab and the /// system keeps Cmd+`, so the chord is Alt (Option), which every platform /// delivers; Option+` types a dead key on a Mac, so the key is matched by /// its position too. Ctrl+` stays the terminal's. int? windowCycleShortcut(KeyEvent event, HardwareKeyboard keyboard) { if (event is KeyUpEvent || !keyboard.isAltPressed || keyboard.isControlPressed || keyboard.isMetaPressed) { return null; } final backquote = event.logicalKey == LogicalKeyboardKey.backquote || event.physicalKey == PhysicalKeyboardKey.backquote; if (!backquote) return null; return keyboard.isShiftPressed ? -1 : 1; } /// The chord as it reads on this platform, for the Windows menu. String windowCycleShortcutLabel([TargetPlatform? platform]) => switch (platform ?? defaultTargetPlatform) { TargetPlatform.macOS || TargetPlatform.iOS => 'Option+`', _ => 'Alt+`', };