BottomNavigationBar 是底部导航条,可以让我们定义底部Tab切换,bottomNavigationBar是
Scaffold组件的参数。
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; }); },
        selectedFontSize: 18, // 选中后的文字大小
       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 自定义底部导航的更多相关文章

  1. 15 Flutter BottomNavigationBar自定义底部导航条 以及实现页面切换 以及模块化

    效果: /**  * Flutter  BottomNavigationBar 自定义底部导航条.以及实现页面切换:  * BottomNavigationBar是底部导航条,可以让我们定义底部Tab ...

  2. BottomNavigationBar 自定义 底部导航条

    在flutter中,BottomNavigationBar 是底部导航条,可以让我们定义底部 Tab 切换,bottomNavigationBar是 Scaffold 组件的参数. BottomNav ...

  3. tab 切换 和 BottomNavigationBar 自定义 底部导航条

    BottomNavigationBar 组件    BottomNavigationBar 是底部导航条,可以让我们定义底部 Tab 切换,bottomNavigationBar是 Scaffold ...

  4. BottomNavigationBar 自定义 底部导航条、以及实现页面切换

    一.Flutter BottomNavigationBar 组件 BottomNavigationBar 是底部导航条,可以让我们定义底部 Tab 切换,bottomNavigationBar是 Sc ...

  5. 【Flutter】容器类组件之Scaffold、TabBar、底部导航

    前言 一个完整的路由页可能会包含导航栏.抽屉菜单(Drawer)以及底部Tab导航菜单等.Flutter Material组件库提供了一些现成的组件来减少开发任务.Scaffold是一个路由页的骨架, ...

  6. 微信小程序-自定义底部导航

    代码地址如下:http://www.demodashi.com/demo/14258.html 一.前期准备工作 软件环境:微信开发者工具 官方下载地址:https://mp.weixin.qq.co ...

  7. 微信小程序自定义底部导航栏组件+跳转

    微信小程序本来封装有底部导航栏,但对于想自定义样式和方法的开发者来说,这并不是很好. 参考链接:https://github.com/ljybill/miniprogram-utils/tree/ma ...

  8. uniapp 小程序实现自定义底部导航栏(tarbar)

    在小程序开发中,默认底部导航栏很难满足实际需求,好在官方给出了自定义形式,效果如下: 话不多说,直接上代码 1.组件 custom-tarbar.vue文件 <template> < ...

  9. 自定义底部导航栏(tabBar)

    前言如果大家用过微信提供的tabBar就会发现,他的tabBar有很大的局限性.暂且不说样式局限性了,他提供的app.json配置文件中没有function.这也就意味着使用它提供的这个组件,你只能用 ...

  10. 小程序 mpvue自定义底部导航栏

    1.在compontents新建文件放入 <template> <section class="tabBar-wrap"> <article clas ...

随机推荐

  1. vscode没有完全汉化怎么办? vs code部分内容没汉化的解决办法

  2. King's Tour 题解

    King's Tour 题面大意 在 \(n\times m\) 的网格中构造一种从 \((1,1)\) 走到 \((a,b)\) 的方案,要求经过所有格子恰好一次,格子之间八联通. 思路分析 模拟赛 ...

  3. 入手react的 第一坑

    npm verb cli /usr/local/bin/node /usr/local/bin/npm npm info using npm@9.8.1 npm info using node@v18 ...

  4. Vue之阻止默认行为

    1.使用原生js实现点击右键阻止默认行为 <!DOCTYPE html> <html lang="en"> <head> <meta ch ...

  5. 飞码LowCode前端技术系列(二):如何便捷配置出页面 | 京东云技术团队

    一.配置解法 飞码LowCode前端技术(一)中飞码提出了至少需要满足2个大能力点以及对应16个细化点.在业务复杂的场景下数据具有流转性质,事件的触发会改变数据.同时也会触发其他事件等情况.飞码使用数 ...

  6. JVM-JVM是如何执行方法调用的

    重载.重写 void invoke(Object obj, Object... args) { ... } void invoke(String s, Object obj, Object... ar ...

  7. win10如何美化cmd[添加新字体+配色方案+窗口栏样式]

    最近学mysql的时候用到很多cmd操作,但是cmd那默认界面实在是丑到没朋友.在网上收集了些资料最后把cmd美化成这样: 修改方法: 1.修改字体,新建一个txt文件,里面粘贴以下代码: Windo ...

  8. Navicat Premium破解工具及教程

    使用Navicat_Keygen_Patch5破解Navicat Premium 更新:2019-06-11 10:16 使用Navicat_Keygen_Patch_v5.0_By_DFoX破解Na ...

  9. 【pwn】[SDCTF 2022]Horoscope--栈溢出,atoi函数绕过

    checksec检查一下,发现只开了nx,然后ida打开直接看主函数 发现fgets函数往s里面读入320个字节的数据,此处可造成溢出,再看看test和debug函数 void debug(){  t ...

  10. Git文件权限与filemode配置方法

    一.问题 Clion是一个跨平台的IDE,今天将工程运行在Ubuntu下,在Git提交时发现有很多文件显示被更改,但是文件内容却是相同的. 二.Git 规则 Git对文件访问权限的管理与配置选项cor ...