外贸网站建设长沙,建设凡科网站,国际贸易平台哪个好,一级a做爰片免费网站孕交视频flutter开发实战-设置bottomNavigationBar中间按钮悬浮的效果
在使用tabbar时候#xff0c;可以使用bottomNavigationBar来设置中间凸起的按钮#xff0c;如下
一、效果图
中间按钮凸起的效果图如下 二、实现代码
我们使用BottomAppBar 一个容器#xff0c;通常与[Sscaf…flutter开发实战-设置bottomNavigationBar中间按钮悬浮的效果
在使用tabbar时候可以使用bottomNavigationBar来设置中间凸起的按钮如下
一、效果图
中间按钮凸起的效果图如下 二、实现代码
我们使用BottomAppBar 一个容器通常与[Sscaffold.bottomNavigationBar]一起使用。
使用的示例代码
Scaffold(bottomNavigationBar: BottomAppBar(color: Colors.white,child: bottomAppBarContents,),floatingActionButton: const FloatingActionButton(onPressed: null),)
设置中间的凸起按钮可以设置BottomAppBar的shape为CircularNotchedRectangle中间悬浮按钮嵌入BottomAppBar 设置notchMargin缺口边距。 设置floatingActionButtonLocationFloatingActionButtonLocation.centerDocked,//放在中间
完整代码如下
import package:flutter/material.dart;class TabDemoPage extends StatefulWidget {const TabDemoPage({super.key});overrideStateTabDemoPage createState() _TabDemoPageState();
}class _TabDemoPageState extends StateTabDemoPage {ListString pageTitles [];ListWidget pageChildren [];int currentIndex 0;overridevoid initState() {// TODO: implement initStatepageTitles [首页,我的];pageChildren [Container(color: Colors.lightBlueAccent,),Container(color: Colors.pinkAccent,)];super.initState();}overridevoid dispose() {// TODO: implement disposesuper.dispose();}Widget build(BuildContext context) {return Scaffold(appBar: AppBar(title: Text(pageTitles[currentIndex]),///导航栏标题centerTitle: true,///导航栏标题居中显示IOS默认居中Android默认靠左),body: pageChildren[currentIndex],bottomNavigationBar: BottomAppBar(shape: CircularNotchedRectangle(), ///中间悬浮按钮嵌入BottomAppBarnotchMargin: 10,///缺口边距child: Row(mainAxisAlignment: MainAxisAlignment.spaceAround,children: [IconButton(icon: Icon(Icons.home),onPressed: (){setState(() {currentIndex 0;});}),IconButton(icon: Icon(Icons.person),onPressed: (){setState(() {currentIndex 1;});}),],),),floatingActionButton: FloatingActionButton(foregroundColor: Colors.white,elevation: 10.0,///阴影onPressed: (){},child: Icon(Icons.add),),floatingActionButtonLocation: FloatingActionButtonLocation.centerDocked,//放在中间);}
}
三、小结
flutter开发实战-设置bottomNavigationBar中间按钮悬浮的效果
学习记录每天不停进步。