refactor: conditionalize profile fields, update chat navigation transitions, and fix provider state management during widget lifecycle

This commit is contained in:
pradeepkumar
2026-03-31 13:05:49 +05:30
parent 418e350fad
commit a96a7b84d8
4 changed files with 36 additions and 17 deletions

View File

@@ -90,16 +90,12 @@ class _ChatScreenState extends ConsumerState<ChatScreen>
}
}
@override
@override
void deactivate() {
// Clear active conversation while ref is still valid (before dispose)
ref.read(messagingProvider.notifier).setActiveConversation(null);
super.deactivate();
}
@override
void dispose() {
// Defer provider modification to avoid "modify during build" error
final notifier = ref.read(messagingProvider.notifier);
Future.microtask(() => notifier.setActiveConversation(null));
WidgetsBinding.instance.removeObserver(this);
_connectionSub?.cancel();
// Stop typing and leave room before disposing