From bc4d642a7bf59e024feb484a448d6d3bbf425c64 Mon Sep 17 00:00:00 2001 From: "sanjeev.p" Date: Wed, 24 Dec 2025 18:11:12 +0530 Subject: [PATCH] FIX_app header freeze fixes --- lib/presentation/layouts/appheader.dart | 25 +++++++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/lib/presentation/layouts/appheader.dart b/lib/presentation/layouts/appheader.dart index c3d7787..9cc0acd 100644 --- a/lib/presentation/layouts/appheader.dart +++ b/lib/presentation/layouts/appheader.dart @@ -108,7 +108,10 @@ class _AppHeaderState extends ConsumerState { builder: (_) { return Positioned( left: offset.dx, - top: offset.dy + size.height + 8, + // top: offset.dy + size.height + 8, + // Reduced +8 to +2 to create an overlap so the mouse never leaves + // a "hoverable" area, which prevents the exit flicker. + top: offset.dy + size.height + 2, child: MouseRegion( onExit: (_) => _hidePopup(), child: Material( @@ -239,8 +242,12 @@ class _AppHeaderState extends ConsumerState { } void _hidePopup() { - _overlayEntry?.remove(); - _overlayEntry = null; + if (_overlayEntry != null) { + _overlayEntry?.remove(); + _overlayEntry = null; + // Optional: add a small setState if needed to refresh the UI layer + if (mounted) setState(() {}); + } } @override @@ -607,6 +614,13 @@ class _AppHeaderState extends ConsumerState { final size = renderBox.size; _showPopup(context, offset, size, popupKey); }, + onExit: (event) { + // We check if the mouse is moving downwards (toward the popup) + // If not moving toward popup, hide it. + if (event.localPosition.dy < 0 || event.localPosition.dx < 0 || event.localPosition.dx > 100) { + _hidePopup(); + } + }, child: Container( padding: const EdgeInsets.symmetric(horizontal: 10, vertical: 6), decoration: BoxDecoration( @@ -659,7 +673,10 @@ class _AppHeaderState extends ConsumerState { Widget _buildPopupItem({required String label, required VoidCallback onTap}) { return _HoverableContainer( label: label, - onTap: onTap, + onTap: () { + _hidePopup(); // Force hide before executing the specific onTap logic + onTap(); + }, normalColor: Colors.white, hoverColor: const Color(0xFFF5F5F5), );