Doubletab cupertinobottomnavigationbar到达家庭页面
我在应用程序中使用Cupertinobottomnavigationbar。一切正常,但是我想实现一个功能。以Spotify为例,您可以在底部navbar的项目中推入新屏幕,并始终通过双击底部努力键返回开始页面。 有没有办法在扑朔迷离中实现这一目标?
class CupterinoBottomNav extends StatelessWidget {
const CupterinoBottomNav({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoTabScaffold(
tabBar: CupertinoTabBar(
backgroundColor: Colors.grey,
items: const [
BottomNavigationBarItem(
icon: Icon(
Icons.home_filled,
size: 28,
),
label: 'Home'),
BottomNavigationBarItem(
icon: Icon(
Icons.text_fields_sharp,
size: 28,
),
label: 'Test'),
],
),
tabBuilder: (context, index) {
switch (index) {
case 0:
return CupertinoTabView(builder: (context) => const Homepage());
case 1:
default:
return CupertinoTabView(builder: (context) => const Test());
}
},
);
}
}
I am using the CupertinoBottomNavigationBar in my app. Everything works well, however there is one feature I would like to implement. Taking Spotify as an example, you can push to new screens within an item of the BottomNavBar and always return to the starting page by double tapping the BottomNavigationBar.
Is there a way to implement this in flutter?
class CupterinoBottomNav extends StatelessWidget {
const CupterinoBottomNav({Key? key}) : super(key: key);
@override
Widget build(BuildContext context) {
return CupertinoTabScaffold(
tabBar: CupertinoTabBar(
backgroundColor: Colors.grey,
items: const [
BottomNavigationBarItem(
icon: Icon(
Icons.home_filled,
size: 28,
),
label: 'Home'),
BottomNavigationBarItem(
icon: Icon(
Icons.text_fields_sharp,
size: 28,
),
label: 'Test'),
],
),
tabBuilder: (context, index) {
switch (index) {
case 0:
return CupertinoTabView(builder: (context) => const Homepage());
case 1:
default:
return CupertinoTabView(builder: (context) => const Test());
}
},
);
}
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使用Inkwell小部件来收听双水龙头,然后有几种方法可以导航到主页。一种方法是使用 name路由然后使用以下方式导航回家:
You can use the InkWell widget to listen for the double tap and then there are a couple of ways to navigate home to your home page. One way would be to use name routes and then navigate home using: