20、Scaffold属性 BottomNavigationBar 自定义底部导航
BottomNavigationBar 常见的属性

BottomNavigationBar 底部菜单选中
class MyFlutter1 extends StatefulWidget {
const MyFlutter1({super.key});
@override
State<MyFlutter1> createState() => _MyFlutter1State();
}
class _MyFlutter1State extends State<MyFlutter1> {
int _currentIndex =0;
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("这是导航栏")),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex, //默认选中第几个
iconSize: 35,
type:BottomNavigationBarType.fixed, //如果底部有4个或者4个以上的进行选择
fixedColor: const Color.fromARGB(255, 54, 244, 171), //选中的颜色
onTap: (index){ //选中变化回调函数
print("监听$index");
setState(() {
_currentIndex = index;
});
},
items: const [
BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
BottomNavigationBarItem(icon: Icon(Icons.timeline), label: "时间"),
BottomNavigationBarItem(icon: Icon(Icons.my_library_add), label: "我的"),
]),
body: const Center(
child: Column(
mainAxisAlignment: MainAxisAlignment.center,
children: [],
)),
);
}
}
BottomNavigationBar 底部菜单选中 换页面内容
class MyFlutter1 extends StatefulWidget {
const MyFlutter1({super.key});
@override
State<MyFlutter1> createState() => _MyFlutter1State();
}
class _MyFlutter1State extends State<MyFlutter1> {
int _currentIndex =0;
final List<Widget> _pages = [
const HomePage(),
const TimePag(),
const myHome()
];
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(title: const Text("这是导航栏")),
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex, //默认选中第几个
fixedColor: const Color.fromARGB(255, 54, 244, 171), //选中的颜色
unselectedItemColor: Colors.grey, // 设置未选中按钮的颜色为灰色
onTap: (index){ //选中变化回调函数 print("监听$index"); setState(() { _currentIndex = index; }); },
items: const [
BottomNavigationBarItem(icon: Icon(Icons.home), label: "首页"),
BottomNavigationBarItem(icon: Icon(Icons.timeline), label: "时间"),
BottomNavigationBarItem(icon: Icon(Icons.my_library_add), label: "我的"),
]),
body: _pages[_currentIndex],
);
}
}
20、Scaffold属性 BottomNavigationBar 自定义底部导航的更多相关文章
- 15 Flutter BottomNavigationBar自定义底部导航条 以及实现页面切换 以及模块化
效果: /** * Flutter BottomNavigationBar 自定义底部导航条.以及实现页面切换: * BottomNavigationBar是底部导航条,可以让我们定义底部Tab ...
- BottomNavigationBar 自定义 底部导航条
在flutter中,BottomNavigationBar 是底部导航条,可以让我们定义底部 Tab 切换,bottomNavigationBar是 Scaffold 组件的参数. BottomNav ...
- tab 切换 和 BottomNavigationBar 自定义 底部导航条
BottomNavigationBar 组件 BottomNavigationBar 是底部导航条,可以让我们定义底部 Tab 切换,bottomNavigationBar是 Scaffold ...
- BottomNavigationBar 自定义 底部导航条、以及实现页面切换
一.Flutter BottomNavigationBar 组件 BottomNavigationBar 是底部导航条,可以让我们定义底部 Tab 切换,bottomNavigationBar是 Sc ...
- 【Flutter】容器类组件之Scaffold、TabBar、底部导航
前言 一个完整的路由页可能会包含导航栏.抽屉菜单(Drawer)以及底部Tab导航菜单等.Flutter Material组件库提供了一些现成的组件来减少开发任务.Scaffold是一个路由页的骨架, ...
- 微信小程序-自定义底部导航
代码地址如下:http://www.demodashi.com/demo/14258.html 一.前期准备工作 软件环境:微信开发者工具 官方下载地址:https://mp.weixin.qq.co ...
- 微信小程序自定义底部导航栏组件+跳转
微信小程序本来封装有底部导航栏,但对于想自定义样式和方法的开发者来说,这并不是很好. 参考链接:https://github.com/ljybill/miniprogram-utils/tree/ma ...
- uniapp 小程序实现自定义底部导航栏(tarbar)
在小程序开发中,默认底部导航栏很难满足实际需求,好在官方给出了自定义形式,效果如下: 话不多说,直接上代码 1.组件 custom-tarbar.vue文件 <template> < ...
- 自定义底部导航栏(tabBar)
前言如果大家用过微信提供的tabBar就会发现,他的tabBar有很大的局限性.暂且不说样式局限性了,他提供的app.json配置文件中没有function.这也就意味着使用它提供的这个组件,你只能用 ...
- 小程序 mpvue自定义底部导航栏
1.在compontents新建文件放入 <template> <section class="tabBar-wrap"> <article clas ...
随机推荐
- Treap树学习笔记
等我写完. 普通fhq treap: enum { Maxn = 1000005 }; struct FHQTreap { int lson[Maxn], rson[Maxn], data[Maxn] ...
- 基于SpringBoot+Netty实现即时通讯(IM)功能
简单记录一下实现的整体框架,具体细节在实际生产中再细化就可以了. 第一步 引入netty依赖 SpringBoot的其他必要的依赖像Mybatis.Lombok这些都是老生常谈了 就不在这里放了 &l ...
- 回文自动机(PAM) 详解
PAM 是一种高效存储字符串中所有回文子串的自动机,用于解决回文串相关问题. 虽然代码稍微长一点,但写起来比 manacher 容易很多,毕竟没有加了一堆字符再转回原串的若干上取整下取整问题. 前置知 ...
- 【日常收支账本】【Day04】优化编辑动账记录的操作——QTableWidget单元格设置QComboBox控件
一.项目地址 https://github.com/LinFeng-BingYi/DailyAccountBook 二.新增 1. 在表格中设置选项列表,让用户更快地编辑动账记录 1.1 功能详述 为 ...
- OceanBase金融SQL、亿万级别据量优化案例(Row_number 开窗 + 分页SQL)
最近优化了不少SQL,简单的SQL顺手搞了不好意思发出来了忽悠人,复杂很考验逻辑思维的,但是又不想分享出来(自己收藏的案例),怕被人抄袭思路. 今天遇到一条很有意思的SQL案例: 性能SQL(金融行 ...
- CDQZ DS 题单总结(上)
Preview: 个人认为是一套非常好的题单,能在各个方面练习 DS 水平,并且很多题型也是比赛当中的经典题 题单链接 Challenge 0: 简单的数组,懒得写了. Challenge 1: 考虑 ...
- easyupload
打开界面就是一个文件上传 的界面 然后在bp试了很多种方法都没有成功,还是看了wp 这里需要利用到.use.ini那为什么不用.heaccess?好像这种方法被过滤了,当时我用的时候没有成功 这里的话 ...
- python循环之for循环
当我们想让列表中的元素一个一个打印出时,用多个print()就显得代码很繁琐了,这是我们就可以用到循环 list_1 = ['one', 'two', 'three', 'four', 'five'] ...
- 【python】大作业进度一 | 解析题目
1.爬取生成txt文件(整本小说) 2.图形化界面的实现
- C++20语言核心特性的变化
using for Enumeration Values 对比一下C++20前后的区别: enum class State { open, progress, done = 9 }; // Bef ...