对于第一个标签栏:我在DispayMoreScreen上有一个注销按钮。对于Logout按钮操作,app会正确导航到应用程序的根目录。
Navigator.of(context).pushReplacementNamed('/')
带有工作导航的Tabbar:
@override
Widget build(BuildContext context) {
return new Scaffold(
bottomNavigationBar: new Material(
color: Colors.white,
child: new TabBar(controller: controller, labelColor: Colors.blue[900], tabs: <Tab>[
new Tab(icon: new Icon(Icons.local_shipping, color: Colors.blue[900], size: 30.0), text: 'A'),
new Tab(icon: new Icon(Icons.insert_drive_file, color: Colors.blue[900], size: 30.0), text: 'B'),
new Tab(icon: new Icon(Icons.more_horiz, color: Colors.blue[900], size: 30.0), text: 'C'),
])),
body: new TabBarView(controller: controller, children: <Widget>[
new ShipmentScreen.ShipmentTab(),
new InvoiceScreen.InvoiceTab(),
new DisplayMoreScreen.MoreTab(),
])
);
}
但是当我实施CupertinoTabBar时,注销应用程序停留在同一个屏幕上。
@override
Widget build(BuildContext context) {
return new CupertinoTabScaffold(
tabBar: new CupertinoTabBar(
backgroundColor: Colors.white,
activeColor: Colors.blue[900],
items: [
new BottomNavigationBarItem(
icon: new Icon(Icons.local_shipping),
title: new Text("A")
),
new BottomNavigationBarItem(
icon: new Icon(Icons.insert_drive_file),
title: new Text("B")
),
new BottomNavigationBarItem(
icon: new Icon(Icons.more_horiz),
title: new Text("C")
)
]
),
tabBuilder: (BuildContext context, int index) {
return new CupertinoTabView(
builder: (BuildContext context) {
switch(index) {
case 0:
return new ShipmentScreen.ShipmentTab();
case 1:
return new InvoiceScreen.InvoiceTab();
case 2:
return new DisplayMoreScreen.MoreTab();
}
},
);
}