In my project I am using go_router: ^12.1.3
. I am having trouble with the back button while using router.pop()
/context.pop()
.
My route is something like /community_tab_selected/0/profile_subroute_from_community
. This redirects from the Community Screen to the Profile Screen in my app. When I press the back button in Profile Screen using router.pop()
/context.pop()
, I want it to redirect to /community_tab_selected/0
but it redirects me to /dashboard
which is base route. How can I achieve proper pop() functionality so that it pops the shell route(profile_subroute_from_community
) and leads me to the route of /community_tab_selected/0
Community route
final communityTab = GoRoute(
name: ROUTE.community_tab_selected,
path: '/community_tab_selected/:index',
pageBuilder: (context, state) {
return createRoutePage(
state.pageKey,
DashboardPage(
initialIndex: "1",
communityTabParams:
CommunityChannelPageQueryParams.fromJson(state.pathParameters),
),
opaque: false,
);
},
routes: [
ShellRoute(
builder: (context, state, child) {
return child;
},
routes: [
profileSubrouteFromCommunity,
],
),
],
);
ShellRoute for Profile
final profileSubrouteFromCommunity = GoRoute(
name: ROUTE.profile_subroute_from_community,
path: 'profile_subroute_from_community/:userid',
pageBuilder: (context, state) {
return createRoutePage(
state.pageKey,
const ProfilePage(),
opaque: false,
);
},
);