admin管理员组文章数量:1123508
I have a GUI which uses BottomNavigationBar
, Drawer
and go_router
with a similar routing table:
GoRouter(
routes: [
GoRoute(
path: '/login',
),
GoRoute(
path: '/settings',
routes: [
GoRoute(
path: 'navigation',
),
],
),
ShellRoute(
routes: [
GoRoute(
path: '/dashboard',
),
GoRoute(
path: '/alers',
),
GoRoute(
path: '/users',
),
pageBuilder: (...) {
return ScaffoldWithNavigationShell(child: child),
},
]
),
],
)
The similar GUI widget:
class _ScaffoldWithNavigationShellState extends State<...> {
Widget build(...) {
final navigationItems = _getDynamicallyGeneratedItems();
return Scaffold(
body: widget.navigationShell,
bottomNavigation: BottomNavigationBar(
items: navigationItems,
onTap: _changeDestination,
),
);
}
}
void _changeDestination(int index) {
final navigationItems = _getDynamicallyGeneratedItems();
final currentNavigationItem = navigationItems[index];
// go to specific route, e.g. /users
context.go(currentNavigationItem.path);
}
The navigationItems
are built dynamically on the screen with a route /settings/navigation
where user can change the sequence of naviation items, add new ones or remove them.
Let's say the user goes on /users
route. To access the navigation screen the user calls a Drawer
where he than pushes to route /settings
, and then pushes to the route /settings/navigation
. Let's say the user removed the users item from available navigation items.
The sequence of user actions:
- User click on users item, context.go('/users').
- User opens the
Drawer
. - User clicks on
Settings
, context.push('/settings'). - User clicks on
Navigation
, context.push('/settings/navigation'). - User removes users item.
- User clicks back to return to
Settings
screen fromNavigation
. - User closes the
Drawer
.
The new selected item must be alerts with alerts content.
As I use ChangeNotifier
for management of navigation items with InheritedNotifier
widget the changes are reflected on the screen with BottomNavigationBar
, i.e. the removed navigation item is disappeared but the content of widget linked to that route is still visible. So I see the selected item alerts but the body of Scaffold
is still users related.
How to refresh (replace?) the top route with all history of pushed routes?
本文标签:
版权声明:本文标题:dart - How to replace the `navigationShell` widget for taken from `ShellRoute` with all pushed page history in flutter? - Stack 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1736571911a1944783.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论