diff --git a/lib/features/agents/presentation/screens/agent_edit_profile_screen.dart b/lib/features/agents/presentation/screens/agent_edit_profile_screen.dart index bbac60b..6cae9ab 100644 --- a/lib/features/agents/presentation/screens/agent_edit_profile_screen.dart +++ b/lib/features/agents/presentation/screens/agent_edit_profile_screen.dart @@ -388,9 +388,16 @@ class _AgentEditProfileScreenState } // Invalidate the agent detail provider so the dashboard refetches - // field values after save (was showing stale cached data). + // field values after save. The provider is keyed by agentProfileId + // (NOT userId), so pull it from the profile payload we just loaded. + final agentProfileId = data.profile['id'] as String?; + if (agentProfileId != null && agentProfileId.isNotEmpty) { + ref.invalidate(agentDetailProvider(agentProfileId)); + } + // Also invalidate by userId as a fallback (covers any screen that + // may key the provider by userId instead). final userId = ref.read(authProvider).user?.id; - if (userId != null) { + if (userId != null && userId != agentProfileId) { ref.invalidate(agentDetailProvider(userId)); } ref.invalidate(_editProfileDataProvider);