flutter 底部按钮导航栏
2019-12-03 21:28 小罗世界 阅读(1301) 评论(0) 收藏 举报动态组件底部导航栏开始:
debugShouCheckeModeBanner属性,他是MaterialApp中的属性,意思就是当我们运行是我们的模拟系统右上角会出席那debug,所以我们要把他取消,因为
debugShouCheckeModeBanner的默认值为ture,所以我们要改为flase才不出现。
return MaterialApp( debugShowCheckedModeBanner: false,
theme属性也是MaterialApp中的内置属性,它主要是负责屏幕主题或者皮肤的设置。
theme: ThemeData( ////主题,皮肤 primaryColor: Colors.pink, ),
bottomNavigationBar属性(组件)主要是我们脚手组件(Scaffold)中的属性,在
bottomNavigationBar中又有多个属性如
BottomNavigationBar:它值底部导航器。
BottomkNavigationBar中又有items[],中括号里又可以写很多组件,
return Scaffold( bottomNavigationBar: BottomNavigationBar( //下栏导航器,bottomNavigationBar(是Scaffold中一个属性) items: [ BottomNavigationBarItem( icon: Icon( Icons.home, color: _bottomNavigationColor, ), title: Text('Home',style: TextStyle( color: _bottomNavigationColor, ), ) ), BottomNavigationBarItem( icon: Icon( Icons.pages, color: _bottomNavigationColor, ), title: Text('pages',style: TextStyle( color: _bottomNavigationColor, ), ) ), BottomNavigationBarItem( icon: Icon( Icons.email, color: _bottomNavigationColor, ), title: Text('email',style: TextStyle( color: _bottomNavigationColor, ), ) ), ], //新知识属性:currentIndex,代表底部导航的索引 currentIndex: _currentIndex,//currentIndex实质就是底部导航的索引 onTap: (int index){ //自动添加数据类索引,因为我们定义的内部参数是int类型 setState(() { //设置State状态,当点击组件时,就触发这个事件 _currentIndex = index;//跳到响应的页面 }); },//BottmNavigationBar中的响应事件onap ),
BottomAppBar:它是指底部导航栏,它里面可以设置颜色和其他的组件
shape属性是属于BottomAppBar中的一个属性,它指当要把一个一个标志和其他的标志融合在一栏上
shape: CircularNotchedRectangle(),//融合 圆形缺口,因为要和底部其他组件融合
而融合我们需要一个浮动交互的标志就是floatingActionButton,
tooltip属性是长按时会出现提醒字幕
floatingActionButton: FloatingActionButton( //可交互的浮动按钮 onPressed: (){ Navigator.push(context, MaterialPageRoute( builder: (context)=>new EmailPage(), ), ); }, tooltip: '这是交互浮动按钮',//设置浮动交互按钮的提醒 child: Icon(Icons.add,color: Colors.pink,), ),
浙公网安备 33010602011771号