我制作bottomNavigationBar如下
List<Widget> pages = [
Dashboard(),
AllServices(),
InformationPage(),
];
int _selectedIndex = 0;
Widget _bottomNavigationBar(int selectedIndex) {
return BottomNavigationBar(
onTap: (int index) => setState(() => _selectedIndex = index),
currentIndex: selectedIndex,
type: BottomNavigationBarType.fixed,
items: <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: new Icon(Icons.home),
title: new Text("Dashboard"),
),
BottomNavigationBarItem(
icon: new Icon(Icons.location_on),
title: new Text("AllServices"),
),
BottomNavigationBarItem(
icon: new Icon(Icons.person),
title:new Text("InformationPage"),
],
);
}
@override
Widget build(BuildContext context) {
return Scaffold(
bottomNavigationBar: _bottomNavigationBar(_selectedIndex),
body: pages[_selectedIndex],
);
}
如果用户在页面之间导航,每件事都是正确的,但是 AllServices 类有两个条件来呈现两个不同的小部件,我想要如果用户在 AllServices 页面中再次 ontap AllServices 底部导航 AllServices 页面再次重建但 ontap 不适用于同一页面再次重建它我怎么解决这个问题?