【发布时间】:2019-06-21 22:55:59
【问题描述】:
我有底部导航栏的视图,当您推送导航栏项目时,会推送一条新路线。
final navigatorKey = GlobalKey<NavigatorState>();
@override
Widget build(BuildContext context) => MaterialApp(
home: Scaffold(
key: _scaffoldKey,
body: _buildBody(context),
bottomNavigationBar: _buildBottomNavigationBar(context),
),
);
void routeToView(routeIndex) {
navigatorKey.currentState.pushNamed(pagesRouteFactories.keys.toList()[routeIndex]);
}
我想防止在当前视图上推送相同的路线。我想将当前路线与我们尝试推送的新路线进行比较,如果相同则忽略推送路线。
如果我们尝试推送的路线相同,我想将视图滚动到顶部
任何想法。
【问题讨论】: