Flutter是谷歌的移动UI框架,能够快速在iOS和Android上构建高质量的原生用户界面。git
IT界著名的尼古拉斯·高尔包曾说:轮子是IT进步的阶梯!热门的框架千篇一概,好用轮子万里挑一!Flutter做为这两年开始崛起的跨平台开发框架,其第三方生态相比其余成熟框架还略有不足,但轮子的数量也已经不少了。本系列文章挑选平常app开发经常使用的轮子分享出来,给你们提升搬砖效率,同时也但愿flutter的生态愈来愈完善,轮子愈来愈多。github
本系列文章准备了超过50个轮子推荐,工做缘由,尽可能每1-2天出一篇文章。markdown
tip:本系列文章合适已有部分flutter基础的开发者,入门请戳:flutter官网app
dependencies: curved_navigation_bar: ^0.3.1 复制代码
import 'package:curved_navigation_bar/curved_navigation_bar.dart'; 复制代码
默认示例:框架
Scaffold( bottomNavigationBar: CurvedNavigationBar( backgroundColor: Colors.blueAccent, items: <Widget>[ Icon(Icons.add, size: 30), Icon(Icons.list, size: 30), Icon(Icons.compare_arrows, size: 30), ], onTap: (index) { //Handle button tap }, ), body: Container(color: Colors.blueAccent), ) 复制代码
与TabBarView一块儿联动使用ide
class CurvedNavigationBarDemo extends StatefulWidget { CurvedNavigationBarDemo({Key key}) : super(key: key); @override _CurvedNavigationBarDemoState createState() => _CurvedNavigationBarDemoState(); } class _CurvedNavigationBarDemoState extends State<CurvedNavigationBarDemo> with SingleTickerProviderStateMixin{ TabController tabController; List colors=[Colors.blue,Colors.pink,Colors.orange]; int currentIndex=0; @override void initState() { // TODO: implement initState super.initState(); tabController = TabController(vsync: this, length: 3)..addListener((){ setState(() { currentIndex=tabController.index; }); }); } @override Widget build(BuildContext context) { return Scaffold( bottomNavigationBar: CurvedNavigationBar( backgroundColor: colors[currentIndex], index: currentIndex, items: <Widget>[ Icon(Icons.home, size: 30), Icon(Icons.fiber_new, size: 30), Icon(Icons.person, size: 30), ], onTap: (index) { //Handle button tap setState(() { currentIndex=index; }); tabController.animateTo(index,duration: Duration(milliseconds: 300), curve: Curves.ease); }, ), body: TabBarView( controller: tabController, children: <Widget>[ Container( color: colors[0], ), Container( color: colors[1], ), Container( color: colors[2], ) ], ) ); } } 复制代码