Android 中有BottomNavigationBar+Fragment切换

而在Flutter也有的BottomNavigationBar

效果图

底部有两种情况

底部导航栏的类型更改其项目的显示方式。如果未指定,则 当少于四个项时,它会自动设置为BottomNavigationBarType.fixed, 否则为BottomNavigationBarType.shifting。

BottomNavigationBarType.fixed,当少于四个项目时的默认值。如果选中的项为非null,则使用fixedColor渲染,否则使用主题的ThemeData.primaryColor。导航栏的背景颜色是默认的材质背景颜色,ThemeData.canvasColor(基本上是不透明的白色)。

BottomNavigationBarType.shifting,当有四个或更多项时的默认值。所有项目都以白色呈现,导航栏的背景颜色与所选项目的BottomNavigationBarItem.backgroundColor相同 。在这种情况下,假设每个项目将具有不同的背景颜色,并且背景颜色将与白色形成鲜明对比。

超出4个默认情况:

代码:

class BottomNavigationBarLnt extends StatefulWidget {
BottomNavigationBarLnt({Key key}) : super(key: key); @override
BottomNavigationBarTest createState() => BottomNavigationBarTest();
} class BottomNavigationBarTest extends State<BottomNavigationBarLnt>{ int _cuurentIndex = 0;
final List<Widget> chiledList = [Home(),Tab2(),Tab3(),Home()];
final List<BottomNavigationBarItem> _listItem = <BottomNavigationBarItem>[
BottomNavigationBarItem(
icon: Icon(Icons.home),
title: Text("Home")
),
BottomNavigationBarItem(
icon: Icon(Icons.book),
title: Text("book")
),
BottomNavigationBarItem(
icon: Icon(Icons.music_video),
title: Text("music")
),
BottomNavigationBarItem(
icon: Icon(Icons.movie),
title: Text("movie")
),
]; @override
Widget build(BuildContext context) {
// TODO: implement build
return Scaffold(
bottomNavigationBar: BottomNavigationBar(
items: _listItem,
fixedColor: Colors.blue,
// type: BottomNavigationBarType.fixed,
currentIndex: _cuurentIndex,
onTap: _onItemTapped,
),
body: chiledList[_cuurentIndex],
);
} void _onItemTapped(int index) {
setState(() {
_cuurentIndex = index;
});
}
}

超过4个item时添加类型  type: BottomNavigationBarType.fixed,

把上面注释的代码打开就行

官方文档
https://docs.flutter.io/flutter/material/BottomNavigationBar-class.html

Flutter -------- BottomNavigationBar 界面切换的更多相关文章

  1. 5、Flutter 实现 ViewPager、bottomNavigationBar 界面切换

    1.前言 首先我们想一下,如果在 Android 中实现 布局切换,通常的思路是: 做一个 viewpager 一组 Fragment 每个 Fragment 绑定一个 xml 最后填充至 viewp ...

  2. 给 Flutter 界面切换来点特效

    本文微信公众号「AndroidTraveler」首发. 背景 我们知道页面之间如果直接切换,会比较生硬,还会让用户觉得很突兀,用户体验不是很好. 因此一般情况下,页面之间的切换为了达到平滑过渡,都会添 ...

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

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

  4. Unity iOS混合开发界面切换思路

    Unity iOS混合开发界面切换思路 最近有很多博友QQ 私信 或则 留言联系我,请教iOS和Unity界面之前相互切换的问题,源代码就不私下发你们了,界面跳转功能的代码我直接贴到下面好了,顺带说i ...

  5. Linux启动界面切换:图形界面-字符界面(转)

    Linux字符界面切换到图形界面 由字符界面切换到图形界面可用两种简单方法实现: 1.在字符界面输入startx或init 5 . 2.通过编辑/etc/inittab文件实现默认进入图形界面. 把其 ...

  6. Html5 Egret游戏开发 成语大挑战(五)界面切换和数据处理

    经过前面的制作,使用Egret的Wing很快完成了开始界面和选关卡界面,下面通常来说就是游戏界面,但此时界面切换和关卡数据还没有准备好,这次讲解界面的切换和关卡数据的解析.前面多次修改了Main.ts ...

  7. php-- Linux图形界面与字符界面切换

    转自:http://blog.163.com/wang_ly2442/blog/static/9494340720128355054551/ 1. 启动时进入字符界面,后来想切换到图形界面:使用sta ...

  8. 参考_Android中,如何新建一个界面,并且实现从当前界面切换到到刚才新建的(另外一个)界面

    参考地址: http://www.crifan.com/android_how_to_create_new_ui_and_switch_to_another_new_ui/ 想要实现,在Android ...

  9. WPF如何实现类似iPhone界面切换的效果(转载)

    WPF如何实现类似iPhone界面切换的效果 (version .1) 转自:http://blog.csdn.net/fallincloud/article/details/6968764 在论坛上 ...

随机推荐

  1. ACL权限

    基本命令 getfacl 文件名 查看文件ACL权限 setfacl [选项] 文件名 设定文件ACL权限 -m 设定ACL权限 -b   删除ACL权限 -x:用户   删除单个用户的ACL权限 s ...

  2. Python如何打印文字对应的索引

    用python编写一个简单的小程序:将文字对应的索引打印出来. test=input('>>>') print(test) l=len(test) print(l) r=range( ...

  3. 常见的监控JVM的几个Linux命令和使用

    jps [root@xxx bin]# jps -l 2007bash: jps: command not found [root@xxx bin]# /opt/jdk1.8.0_181/bin/jp ...

  4. mysql 用户创建,授权

    关于mysql的用户管理,笔记 1.创建新用户 通过root用户登录之后创建 >> grant all privileges on *.* to testuser@localhost id ...

  5. Codeforces C. A Simple Task(状态压缩dp)

    题目描述:  A Simple Task time limit per test 2 seconds memory limit per test 256 megabytes input standar ...

  6. 16、Real-time Personalization using Embeddings for Search Ranking at Airbnb

    一.背景 Airbnb 平台包含数百万种不同的房源,用户可以通过浏览搜索结果页面来寻找想要的房源,我们通过复杂的机器学习模型使用上百种信号对搜索结果中的房源进行排序. 当用户查看一个房源时,他们有两种 ...

  7. 使用CIFAR-10样本数据集测试卷积神经网络(ConvolutionalNeuralNetwork,CNN)

    第一次将例程跑起来了,有些兴趣. 参考的是如下URL: http://www.yidianzixun.com/article/0KNz7OX1 本来是比较Keras和Tensorflow的,我现在的水 ...

  8. 2019牛客多校第一场 A.Equivalent Prefixes

    题目描述 Two arrays u and v each with m distinct elements are called equivalent if and only if RMQ(u,l,r ...

  9. go语言-for循环

    一.for循环语法: for 循环变量初始化:循环条件:循环变量迭代{ 循环体 }案例: 打印10句hello 方式一 package main import "fmt" func ...

  10. dedecms自定义表单提交获取时间跟ip地址

    相信大家在用织梦做网站的时候都用过自定义表单做留言,但是如何查看客户什么时间填写的表单,和客户的IP地址呢? 我在网上找了很多JS文件,但太繁琐了,后来我注意到一个细节,每次我登陆后台,织梦系统都会记 ...