I have a home screen and a detail page. When I navigate to the detail page, Flutter automatically adds a back button in the AppBar that when clicked, goes back to the previous page.
Now using GoRouter, the UrlPathStrategy.path
allows that my detail page is at /detail
and when refreshing the page, it opens the detail page directly. This is all good, however, the problem is, there is no back button after refreshing at /detail
.
Is there a concept, such that GoRouter can infer the Navigation stack based on the route and thus when opening the /detail
page, show a back button that leads to /
(home page)?
My current routes look something like this:
routes: [
GoRoute(
name: "detail",
path: "/detail",
builder: (context, state) => DetailPage(),
),
GoRoute(
name: "home",
path: "/",
builder: (context, state) => HomePage(),
),
],
Probably just put detail route inside home route?
routes: [
GoRoute(
name: "home",
path: "/",
builder: (context, state) => HomePage(),
routes: [
GoRoute(
name: "detail",
path: "/detail",
builder: (context, state) => DetailPage(),
),
],
),
],
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.