'Back button for nested routes in Flutter auto_route (Navigator 2.0)
I have two routes, simple and nested:
AutoRoute(
page: ProfilePage,
path: '/profile',
),
AutoRoute(
children: [
AutoRoute(page: AddressesPage, path: ''),
AutoRoute(page: AddressesAddPage, path: 'add'),
],
name: 'AddressRouter',
page: EmptyRouterPage,
path: '/addresses',
),
The back button is only shown in ProfilePage, despite both using Scaffold with app bar. If this is the expected behaviour, how do I force show the back button in nested route?
Solution 1:[1]
You can add the AutoBackButton to the leading property of the AppBar.
You'll have to do it inside the Scaffold of the AddressesPage, like this:
AppBar(
leading: AutoBackButton(),
...
);
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | Hernan Roiz |
