import 'package:flutter/foundation.dart'; /// Where Ctrl+K / Alt+K pressed on the Chat destination goes: the mounted /// chat screen attaches its quick switcher here, and the app toggles it. class ChatQuickSwitchRequests { VoidCallback? _toggle; /// Makes [toggle] the switcher; the last attached one wins. void attach(VoidCallback toggle) => _toggle = toggle; /// Detaches [toggle] if it is still the attached one. void detach(VoidCallback toggle) { if (_toggle == toggle) _toggle = null; } /// Opens the switcher, or closes it when open. False when no chat screen /// is mounted to show it. bool toggle() { final toggle = _toggle; if (toggle == null) return false; toggle(); return true; } }