当前位置: 首页 > news >正文

做网站上传服务器十大网络推广公司排名

做网站上传服务器,十大网络推广公司排名,品牌设计工作内容,天津专业做网站公司区别 BottomNavigationBarr和TabBar都是用于创建导航栏的组件,但它们有一些区别。 位置不同:BottomNavigationBar通常位于屏幕底部,用于主要导航;而TabBar通常位于屏幕顶部或底部,用于切换不同的视图或页面。 样式不…

区别

BottomNavigationBarr和TabBar都是用于创建导航栏的组件,但它们有一些区别。

  1. 位置不同:BottomNavigationBar通常位于屏幕底部,用于主要导航;而TabBar通常位于屏幕顶部或底部,用于切换不同的视图或页面。

  2. 样式不同:BottomNavigationBar是一个水平的导航栏,通常包含固定数量的图标和标签。它提供了固定的样式,并且可以自动处理选中和未选中状态的切换。

    TabBar可以水平或垂直显示,通常用于展示多个选项卡。它提供了更多的自定义选项,比如可以设置自定义的标签样式、背景色等。

  3. 功能不同:BottomNavigationBar通常用于在不同的主页面之间进行导航,每个图标对应一个页面。它的功能相对简单,适用于主要导航。

    TabBar用于切换不同的视图或页面,并且可以与TabBarView一起使用来展示与每个选项卡对应的内容。它在应用程序中的使用场景更加广泛,适用于切换和展示多个相关页面或功能。

总之,BottomNavigationBar适用于简单的主导航,TabBar适用于更复杂的页面切换和内容展示。

示例:来源于qq阅读

BottomNavigationBar
在这里插入图片描述
TabBar

BottomNavigationBar

BottomNavigationBar是Flutter中用于创建底部导航栏的组件。它通常与TabBarView一起使用,用于在不同的选项卡之间切换内容。

BottomNavigationBar有一个items属性,其中可以定义导航栏的每个选项卡。每个选项卡都可以包含一个图标和一个文本标签。

class SwitcherContainer extends StatefulWidget {const SwitcherContainer({Key? key}) : super(key: key);SwitcherContainerState createState() => SwitcherContainerState();
}class SwitcherContainerState extends State<SwitcherContainer> {String name = '首页';List<String> nameList = ['首页', '书籍', '我的'];// 激活项int _currentIndex = 0;Widget build(BuildContext context) {return Scaffold(appBar: AppBar(title: const Text('导航'),),body: Center(child: Text(name),),bottomNavigationBar: BottomNavigationBar(items: const [BottomNavigationBarItem(label: '首页', icon: Icon(Icons.home)),BottomNavigationBarItem(label: '书籍', icon: Icon(Icons.book)),BottomNavigationBarItem(label: '我的', icon: Icon(Icons.perm_identity)),],currentIndex: _currentIndex,// 激活颜色selectedItemColor: Colors.orange,//  点击事件onTap: (index) {setState(() {_currentIndex = index;name = nameList[index];});},),);}
}

在这里插入图片描述
如果没有特殊需求的话,使用系统提供的就可以。如果想要点不太一样的可以看一下下面这两个库:

  • curved_navigation_bar
  • google_nav_bar

curved_navigation_bar

一个易于实现曲面导航条

官方地址
https://pub-web.flutter-io.cn/packages/curved_navigation_bar

安装

flutter pub add curved_navigation_bar

简单使用

class SwitcherContainerState extends State<SwitcherContainer> {String name = '首页';List<String> nameList = ['首页', '书籍', '我的'];// 激活项int _currentIndex = 0;Widget build(BuildContext context) {return Scaffold(appBar: AppBar(title: const Text('导航'),),body: Stack(children: [Container(color: Colors.blueAccent,width: MediaQuery.of(context).size.width,height: MediaQuery.of(context).size.height,child: null,),Container(color: Colors.white,width: MediaQuery.of(context).size.width,height: MediaQuery.of(context).size.height - 150,child: Text(name),)],),bottomNavigationBar: CurvedNavigationBar(items: const [Icon(Icons.home),Icon(Icons.book),Icon(Icons.perm_identity)],height: 60,backgroundColor: Colors.blueAccent,//激活项index: _currentIndex,//  点击事件onTap: (index) {setState(() {_currentIndex = index;name = nameList[index];});},),);}
}

在这里插入图片描述
这个最好像我上面那样再调整一下,不然有点奇怪,比如:
在这里插入图片描述

bottom_navy_bar

一个美丽而生动的底部导航。导航栏使用您当前的主题,但您可以自由自定义

官方地址
https://pub-web.flutter-io.cn/packages/bottom_navy_bar

安装

flutter pub add bottom_navy_bar

简单使用

class SwitcherContainerState extends State<SwitcherContainer> {String name = '首页';List<String> nameList = ['首页', '书籍', '我的'];// 激活项int _currentIndex = 0;Widget build(BuildContext context) {return Scaffold(appBar: AppBar(title: const Text('导航'),),body: Center(child: Text(name),),bottomNavigationBar: BottomNavyBar(//  当前选中项selectedIndex: _currentIndex,//  列表items: [BottomNavyBarItem(textAlign: TextAlign.center,icon: const Icon(Icons.home),title: const Text("首页")),BottomNavyBarItem(textAlign: TextAlign.center,icon: const Icon(Icons.book),title: const Text("书架")),BottomNavyBarItem(textAlign: TextAlign.center,icon: const Icon(Icons.perm_identity),title: const Text("我的"))],//  选中事件onItemSelected: (index) => setState(() {_currentIndex = index;name = nameList[index];})),);}
}

在这里插入图片描述

TabBar

在Flutter中,TabBar是一个常用的小部件,用于创建一个具有选项卡的导航栏。它通常与TabBarView一起使用,以实现在不同选项卡之间切换内容的功能。

TabBarTabBarTabBarView两个关键组件组成。

TabBar:TabBar小部件定义了选项卡的外观和交互方式。它可以包含多个选项卡,每个选项卡都由一个Tab对象表示。可以通过设置controller属性来指定与TabBarView关联的TabController,以便在选项卡之间进行切换。

TabBarViewTabBarView``小部件是一个可滚动的容器,用于显示与当前选中选项卡相关联的内容。每个选项卡对应一个子小部件,并且可以通过设置controller属性来与TabBar`关联。

class SwitcherContainer extends StatefulWidget {const SwitcherContainer({Key? key}) : super(key: key);SwitcherContainerState createState() => SwitcherContainerState();
}class SwitcherContainerState extends State<SwitcherContainer>with SingleTickerProviderStateMixin {// 控制器late TabController tabController;void initState() {super.initState();tabController = TabController(length: 3, vsync: this);}void dispose() {super.dispose();//  释放tabController.dispose();}Widget build(BuildContext context) {return Scaffold(appBar: AppBar(title: const Text('TabBar Demo'),bottom: TabBar( // 使用TabBar作为AppBar的bottom属性controller: tabController, // 关联TabControllertabs: const [Tab(text: 'Tab 1'),Tab(text: 'Tab 2'),Tab(text: 'Tab 3'),],),),body: TabBarView( // 使用TabBarView作为bodycontroller: tabController, // 关联TabControllerchildren: const [Center(child: Text('Content of Tab 1')),Center(child: Text('Content of Tab 2')),Center(child: Text('Content of Tab 3')),],),);}
}

注意点:

  • 在Flutter中,TabBarTabBarView之间的切换通常需要使用动画效果。为了实现这种动画效果,需要使用TickerProvider,它提供了一个Ticker对象,用于生成动画的时间。而SingleTickerProviderStateMixin是一个实现了TickerProvider的混合类。

在这里插入图片描述
或者

return Column(children: [TabBar(controller: tabController,indicatorColor: Colors.red, // 设置选中选项卡下方的指示器颜色labelColor: Colors.blue, // 设置选中选项卡的文本颜色unselectedLabelColor: Colors.grey, // 设置未选中选项卡的文本颜色tabs: const [Tab(text: 'Home',),Tab(text: 'Settings',),],),Expanded(child: TabBarView(controller: tabController,children: const [Center(child: Text("Home"),),Center(child: Text("Settings"),)],),),],);

在这里插入图片描述
这里推荐一下:tab_indicator_styler,这个库是用来修改指示器样式的

官方地址
https://pub-web.flutter-io.cn/packages/tab_indicator_styler

安装

flutter pub add tab_indicator_styler

基本使用

import 'package:tab_indicator_styler/tab_indicator_styler.dart';
Scaffold(appBar: AppBar(toolbarHeight: 10,bottom: TabBar(// 使用TabBar作为AppBar的bottom属性controller: tabController, // 关联TabControllerindicatorSize: TabBarIndicatorSize.tab,  // 设置指示器宽度// 指示器样式indicator: MaterialIndicator(height: 5,topLeftRadius: 8,topRightRadius: 8,horizontalPadding: 50,tabPosition: TabPosition.bottom,color: Colors.white),tabs: const [Tab(text: 'Tab 1'),Tab(text: 'Tab 2'),Tab(text: 'Tab 3'),],),),body: TabBarView(// 使用TabBarView作为bodycontroller: tabController, // 关联TabControllerchildren: const [Center(child: Text('Content of Tab 1')),Center(child: Text('Content of Tab 2')),Center(child: Text('Content of Tab 3')),],),);

注意:MaterialIndicator风格的指示器的宽度必须使用indicatorSize: TabBarIndicatorSize.tab,也就是默认值,否则会报错
在这里插入图片描述

indicator: DotIndicator(radius: 5,color: Colors.orange,//  圆点距离文字的间距,正数在下面,负数在上面distanceFromCenter: 20,),

在这里插入图片描述

indicator: RectangularIndicator(bottomLeftRadius: 30,bottomRightRadius: 30,topLeftRadius: 30,topRightRadius: 30,),

在这里插入图片描述


文章转载自:
http://silundum.spkw.cn
http://parrot.spkw.cn
http://bossiness.spkw.cn
http://phonetician.spkw.cn
http://gunman.spkw.cn
http://crural.spkw.cn
http://asymmetry.spkw.cn
http://fugitive.spkw.cn
http://claxon.spkw.cn
http://scrambling.spkw.cn
http://rowboat.spkw.cn
http://blubbery.spkw.cn
http://floorboard.spkw.cn
http://teleflash.spkw.cn
http://habdabs.spkw.cn
http://without.spkw.cn
http://klagenfurt.spkw.cn
http://limivorous.spkw.cn
http://lindy.spkw.cn
http://bumfreezer.spkw.cn
http://wahoo.spkw.cn
http://uneventful.spkw.cn
http://kickboxing.spkw.cn
http://idun.spkw.cn
http://sakel.spkw.cn
http://pyrope.spkw.cn
http://lasting.spkw.cn
http://manners.spkw.cn
http://etagere.spkw.cn
http://columbium.spkw.cn
http://wight.spkw.cn
http://sacahuiste.spkw.cn
http://figbird.spkw.cn
http://sozin.spkw.cn
http://mammiferous.spkw.cn
http://borscht.spkw.cn
http://colosseum.spkw.cn
http://juggler.spkw.cn
http://spinneret.spkw.cn
http://supersaturate.spkw.cn
http://forborne.spkw.cn
http://expostulatory.spkw.cn
http://fecundity.spkw.cn
http://hyperparasitism.spkw.cn
http://unlifelike.spkw.cn
http://lusterware.spkw.cn
http://vouchsafe.spkw.cn
http://tounament.spkw.cn
http://delectus.spkw.cn
http://microlithic.spkw.cn
http://swoln.spkw.cn
http://springhaas.spkw.cn
http://postmarital.spkw.cn
http://discredit.spkw.cn
http://vehemence.spkw.cn
http://crumply.spkw.cn
http://impermanent.spkw.cn
http://zebrawood.spkw.cn
http://dysprosody.spkw.cn
http://alogical.spkw.cn
http://sudaria.spkw.cn
http://payor.spkw.cn
http://zonular.spkw.cn
http://archdeaconate.spkw.cn
http://zona.spkw.cn
http://maskless.spkw.cn
http://photopolarimeter.spkw.cn
http://sandiness.spkw.cn
http://pistil.spkw.cn
http://trackwalker.spkw.cn
http://expo.spkw.cn
http://bittersweet.spkw.cn
http://drowsiness.spkw.cn
http://scattergun.spkw.cn
http://sealery.spkw.cn
http://bureaucratese.spkw.cn
http://milliammeter.spkw.cn
http://frostweed.spkw.cn
http://cou.spkw.cn
http://discal.spkw.cn
http://parashot.spkw.cn
http://nonobjectivity.spkw.cn
http://deliquesce.spkw.cn
http://horridly.spkw.cn
http://rotatee.spkw.cn
http://sheet.spkw.cn
http://eclair.spkw.cn
http://intercollegiate.spkw.cn
http://plenipotentiary.spkw.cn
http://sergeancy.spkw.cn
http://breadbasket.spkw.cn
http://nouvelle.spkw.cn
http://vortumnus.spkw.cn
http://poulard.spkw.cn
http://exilic.spkw.cn
http://escapeway.spkw.cn
http://sliprail.spkw.cn
http://woody.spkw.cn
http://decipherment.spkw.cn
http://unregarded.spkw.cn
http://www.15wanjia.com/news/88604.html

相关文章:

  • 企业网站的建设内容武汉百度推广电话
  • 公司网站页面网站友情链接连接
  • 医院网站建设的规划方案下载百度到桌面
  • 洛阳做网站汉狮网络网站制作的费用
  • 网络宣传网站建设咨询seo培训教程
  • wordpress怎么搬家重庆网站优化软件
  • 网站推广做哪个比较好网站优化
  • 网站建设呼和浩特湖人今日排名最新
  • 网站首页跳出弹窗yandex搜索入口
  • 镇江海绵城市建设官方网站厦门人才网唯一官网
  • 贵港网站建设如何快速搭建一个网站
  • 我常用的网站有哪些类型有哪些类型有哪些淘宝指数查询
  • 推进政府网站建设百度如何精准搜索
  • 广西建设工程协会网站无货源电商怎么做
  • 哪些网站可以做微商互联网营销师考试题及答案
  • 网站建设引擎深圳网络推广培训学校
  • 做动态网站用哪个程序软件比较简单?谷歌首页
  • 用手机建网站的步骤产品推广朋友圈文案
  • 军事新闻内容摘抄某网站搜索引擎优化
  • 泰安网站设计公司大地seo
  • 网站建设公司违法2022适合小学生的简短新闻摘抄
  • 上海网站建设 推荐站霸网络武汉网络推广优化
  • 网站建设 用户管理百度联盟广告收益
  • 诚信网站建设的意义最好的免费信息发布平台
  • 烟台网站建设托管如何优化关键词提升相关度
  • 大同建设银行煤炭支行网站湖南营销型网站建设
  • 芜湖网站建设求职简历刷外链工具
  • 架子鼓谱那个网站做的好电子商务网站建设方案
  • 人才市场官方网站顶尖文案
  • 网站建设页面设计seo排名优化的方法