博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
flutter 带未读消息的底部导航
阅读量:6759 次
发布时间:2019-06-26

本文共 3293 字,大约阅读时间需要 10 分钟。

bottom_tab_bar, 用法和bottom_navigation_bar一样,但是新增了一些属性的用法

items : List<BottomTabBarItem>

bottom navigation bar 里面的 icon and title.

onTap : ValueChanged<int>

回调,带的是tab的index The callback that is called when a item is tapped.

The widget creating the bottom navigation bar needs to keep track of the current index and call setState to rebuild it with the newly provided index.

currentIndex : int

The index into [items] of the current active item. 当前激活的是哪一个tab

type : BottomTabBarType

Defines the layout and behavior of a [BottomTabBar].

See documentation for [BottomTabBarType] for information on the meaning of different types.

fixedColor : Color

The color of the selected item when bottom navigation bar is [BottomTabBarType.fixed].

If [fixedColor] is null then the theme's primary color, [ThemeData.primaryColor], is used. However if [BottomTabBar.type] is [BottomTabBarType.shifting] then [fixedColor] is ignored.

iconSize : double

The size of all of the [BottomTabBarItem] icons.

See [BottomTabBarItem.icon] for more information.

[新增] isAnimation : bool

动画是否开启,默认是开起的

[新增] badgeColor : Color

未读消息的颜色,默认是fixedColor

[新增] isInkResponse : bool

按压水墨屏效果是否开启,默认是开启的, 还是带动画的,不太适合我们的正常项目

[新增] badge : Widget

未读消息,是一个widget,可以自定义样式

[新增] badgeNo : String

未读消息

How to Use?

first import dependeny in pubspec.yaml

dependencies:  flutter:    sdk: flutter  bottom_tab_bar:    git: https://github.com/LiuC520/flutter_bottom_tab_bar.git复制代码

example:

class HomeState extends State
with SingleTickerProviderStateMixin { TabController _tabController; int _selectedIndex = 1; String badgeNo1; var titles = ['home', 'video', 'find', 'smallvideo', 'my']; var icons = [ Icons.home, Icons.play_arrow, Icons.child_friendly, Icons.fiber_new, Icons.mic_none ]; @override void initState() { super.initState(); _tabController = new TabController(vsync: this, initialIndex: 1, length: titles.length); badgeNo1 = '12'; } void _onItemSelected(int index) { setState(() { _selectedIndex = index; badgeNo1 = ''; }); } final _widgetOptions = [ Text('Index 0: Home'), Text('Index 1: Video'), Text('Index 2: find someone'), Text('Index 3: small Video'), Text('Index 4: My'), ]; @override Widget build(BuildContext context) { return Scaffold( appBar: AppBar( title: Text('Bottom Tab Bar'), actions:
[new Icon(Icons.photo_camera)], ), bottomNavigationBar: BottomTabBar( items:
[ BottomTabBarItem( icon: Icon(icons[0]), title: Text(titles[0]), badgeNo: badgeNo1), BottomTabBarItem(icon: Icon(icons[1]), title: Text(titles[1])), BottomTabBarItem(icon: Icon(icons[2]), title: Text(titles[2])), BottomTabBarItem( icon: Icon(icons[3]), activeIcon: Icon(icons[3]), title: Text(titles[3])), BottomTabBarItem(icon: Icon(icons[4]), title: Text(titles[4])), ], fixedColor: Colors.blue, currentIndex: _selectedIndex, onTap: _onItemSelected, type: BottomTabBarType.fixed, isAnimation: false, isInkResponse: false, badgeColor: Colors.green, ), body: Center( child: _widgetOptions.elementAt(_selectedIndex), ), ); }}复制代码

转载地址:http://ixbeo.baihongyu.com/

你可能感兴趣的文章
使用PL/SQL连接Oracle时报错ORA-12541: TNS: 无监听程序
查看>>
Mac011--DbWrench Database安装
查看>>
[原]Flash研究(一)——本地通讯
查看>>
bootStrap table 和 JS 开发过程中遇到问题汇总
查看>>
【小知识点】input输入框在安卓以及IOS手机中光标及字体不居中解决方法
查看>>
VB 设置循环,以及弹出messageBox
查看>>
经典算法-链表(golang)
查看>>
leetcode — search-a-2d-matrix
查看>>
魔板 bfs() 预处理,记录每种状态。然后状态置换,(重点要用到全排列的hash记录状态)...
查看>>
构建之法课后作业第一次作业(15个题选一个)
查看>>
操作redis方法
查看>>
C语言函数
查看>>
Python3-异常处理
查看>>
Python-简单打印进度条
查看>>
【02】天气查询应用(第二课)
查看>>
监听微信返回按钮
查看>>
第二次实验报告
查看>>
HDU ACM 3790 最短路径问题
查看>>
python生成器
查看>>
linux 安装 ftp
查看>>