flutter - 页面中的颤振导航栏
问题描述
我在模态底部表的中间添加了一个导航栏。我希望它在您单击它们时显示不同的内容,例如位置或其他详细信息。这是它的外观截图:
https://gyazo.com/6b81b3b89ec19a0410bb5345dc2b511c
这是我正在关注的教程:
https://api.flutter.dev/flutter/material/BottomNavigationBar-class.html
在我的代码中,我可以只添加这部分代码:
BottomNavigationBar(
backgroundColor: Colors.deepPurple,
selectedItemColor: Colors.grey,
unselectedItemColor: Colors.white,
elevation: 0,
items: const <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
label: 'Details',
),
BottomNavigationBarItem(
icon: Icon(Icons.business),
label: 'Describtion',
),
BottomNavigationBarItem(
icon: Icon(Icons.school),
label: 'Location',
),
],
currentIndex: _selectedIndex,
onTap: _onItemTapped,
),
我无法添加设置状态和内容,因为它给了我整个班级的错误。我应该添加什么才能更改您在导航栏下看到的文本?
解决方案
为了能够像文档中那样使用底部栏,您应该使屏幕小部件有状态。阅读文档中的代码,您会看到脚手架是在有状态小部件的状态类中构建的。
推荐阅读
- java - 如何避免这种情况下的instanceof?
- visual-studio-code - VSCode 冻结并停止响应
- java - Log4j2:如何说服它 log4j-core.jar 的类确实存在?
- azure-devops - 如何允许运行时参数使用空字符串?
- javascript - 为什么使用 mywindow.print() 从 pdf 文件中排除图像?
- asp.net - 实体框架 1-1 和 1 至 *
- java - 如何检查数据库的 a 分支中是否存在子项,以便我可以根据该子项返回值
- java - 在不重新启动 jvm 的情况下阻止 java 代理
- agda - 由于定义等式约束,Agda 不会让我用匹配类型的术语填充类型的空洞
- c++ - Difference between &++x and &x++