From c9b888df79e33b89210a95844241db0a1d904cab Mon Sep 17 00:00:00 2001 From: cogwheel0 <172976095+cogwheel0@users.noreply.github.com> Date: Fri, 5 Dec 2025 22:24:36 +0530 Subject: [PATCH] fix(navigation): Ensure context is mounted before navigation and improve error handling --- lib/core/services/app_intents_service.dart | 3 ++- lib/features/chat/widgets/modern_chat_input.dart | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/core/services/app_intents_service.dart b/lib/core/services/app_intents_service.dart index 26c200b..e6e47f2 100644 --- a/lib/core/services/app_intents_service.dart +++ b/lib/core/services/app_intents_service.dart @@ -370,7 +370,7 @@ class AppIntentCoordinator extends _$AppIntentCoordinator { await Future.delayed(const Duration(milliseconds: 50)); final context = NavigationService.navigatorKey.currentContext; - if (context == null) { + if (context == null || !context.mounted) { throw StateError('Navigation context not available.'); } @@ -378,6 +378,7 @@ class AppIntentCoordinator extends _$AppIntentCoordinator { FocusScope.of(context).unfocus(); // Navigate to voice call page with new conversation flag + if (!context.mounted) return; await Navigator.of(context).push( MaterialPageRoute( builder: (_) => const VoiceCallPage(startNewConversation: true), diff --git a/lib/features/chat/widgets/modern_chat_input.dart b/lib/features/chat/widgets/modern_chat_input.dart index b890208..2afb1dc 100644 --- a/lib/features/chat/widgets/modern_chat_input.dart +++ b/lib/features/chat/widgets/modern_chat_input.dart @@ -1965,7 +1965,7 @@ class _ModernChatInputState extends ConsumerState height: IconSize.small + 1, color: iconUrl.endsWith('.svg') ? iconColor : null, colorBlendMode: BlendMode.srcIn, - errorBuilder: (_, __, ___) => Icon( + errorBuilder: (_, _, _) => Icon( icon, size: IconSize.small + 1, color: iconColor, @@ -2732,7 +2732,7 @@ class _ModernChatInputState extends ConsumerState fit: BoxFit.cover, color: iconUrl.endsWith('.svg') ? iconColor : null, colorBlendMode: BlendMode.srcIn, - errorBuilder: (_, __, ___) => Icon( + errorBuilder: (_, _, _) => Icon( Platform.isIOS ? CupertinoIcons.sparkles : Icons.auto_awesome, color: iconColor, size: IconSize.modal,