refactor: update back navigation to prioritize popping the route stack before defaulting to home

This commit is contained in:
pradeepkumar
2026-03-31 20:41:01 +05:30
parent 8a982bdf3d
commit c2c1b51777
3 changed files with 16 additions and 2 deletions

View File

@@ -154,7 +154,13 @@ class AgentNetworkScreen extends ConsumerWidget {
child: Row( child: Row(
children: [ children: [
GestureDetector( GestureDetector(
onTap: () => context.go('/home'), onTap: () {
if (Navigator.of(context).canPop()) {
Navigator.of(context).pop();
} else {
context.go('/home');
}
},
child: const Icon( child: const Icon(
Icons.arrow_back_ios_new_rounded, Icons.arrow_back_ios_new_rounded,
size: 18, size: 18,

View File

@@ -122,7 +122,13 @@ class _AgentSearchScreenState extends ConsumerState<AgentSearchScreen> {
child: Row( child: Row(
children: [ children: [
GestureDetector( GestureDetector(
onTap: () => context.go('/home'), onTap: () {
if (Navigator.of(context).canPop()) {
Navigator.of(context).pop();
} else {
context.go('/home');
}
},
child: const Padding( child: const Padding(
padding: EdgeInsets.only(right: 8), padding: EdgeInsets.only(right: 8),
child: Icon( child: Icon(

View File

@@ -75,6 +75,8 @@ class _ConversationsScreenState extends ConsumerState<ConversationsScreen> {
_isSearchActive = false; _isSearchActive = false;
_searchController.clear(); _searchController.clear();
}); });
} else if (Navigator.of(context).canPop()) {
Navigator.of(context).pop();
} else { } else {
context.go('/home'); context.go('/home');
} }