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

滨江网站制作制作网站的步骤

滨江网站制作,制作网站的步骤,复旦大学精品课程网站,汉口网站关键词排名在我们开发过程中经常会使用到悬浮菜单的使用,当我们滑动到指定位置后,菜单会自动悬浮。 实现效果如下(左为滑动前、右为滑动后): 上述便是通过NestedScrollView 、SliverAppBar实现的效果,通过两个控件我…

在我们开发过程中经常会使用到悬浮菜单的使用,当我们滑动到指定位置后,菜单会自动悬浮。

实现效果如下(左为滑动前、右为滑动后):

上述便是通过NestedScrollView 、SliverAppBar实现的效果,通过两个控件我们便可以实现上述的效果。

废话不多说直接上代码,代码的实现原理会以注释的形式实现:

import 'package:aboxmini/view/home/room/room_device_page.dart';
import 'package:flutter/material.dart';
import '../../model/app_model.dart';class HomeTabBar extends StatefulWidget {const HomeTabBar({super.key});@overrideState<HomeTabBar> createState() => _HomeTabBarState();
}class _HomeTabBarState extends State<HomeTabBar> with TickerProviderStateMixin {/// 自定义的一个类,此类可获取屏幕宽度等final AppModel _appModel = AppModel.share();/// 设置 中间展示区域的高度final double _topHeight = 180 + AppModel.share().safeTop + kToolbarHeight;/// 分栏控制器late TabController tabController = TabController(length: 3, vsync: this);/// 分栏控制器每一个标题final _tabs = <String>["Tab 1", "Tab 2", "Tab 3"];@overridevoid dispose() {tabController.dispose();super.dispose();}@overrideWidget build(BuildContext context) {return DefaultTabController(length: _tabs.length,child: NestedScrollView(headerSliverBuilder: (BuildContext context, bool innerBoxIsScrolled) {return <Widget>[SliverOverlapAbsorber(handle: NestedScrollView.sliverOverlapAbsorberHandleFor(context),sliver: SliverAppBar(/// 取消系统导航左边按钮leading: Container(),/// 设置背景色backgroundColor: Colors.white,/// 设置左边按钮宽度leadingWidth: _appModel.width,centerTitle: false,pinned: true,floating: false,snap: false,primary: true,/// 设置分栏区域上面的高度expandedHeight: 230.0,elevation: 10,//是否显示阴影,直接取值innerBoxIsScrolled,展开不显示阴影,合并后会显示forceElevated: innerBoxIsScrolled,///自定义导航和中间内容的展示flexibleSpace: _displayNavAndEnvInfo(),/// TabBar 分栏标题bottom: _addTabBar(),),),];},/// 分栏展示的页面信息body: _addTabBarView(),),);}/// 自定义导航和中间内容展示Widget _displayNavAndEnvInfo() {return Container(color: Colors.white,width: _appModel.width,height: _topHeight,child: Column(children: <Widget>[_addNav(),_displayEnvDevice(),],),);}/// 自定义导航 可随意定制Widget _addNav() {return SizedBox(width: _appModel.width,height: _appModel.safeTop + kToolbarHeight,child: Container(margin: EdgeInsets.only(top: _appModel.safeTop),height: kToolbarHeight,width: _appModel.width,alignment: Alignment.centerLeft,child: Row(children: <Widget>[GestureDetector(onTap: () {widget.z.toggle!();},child: Row(children: [Container(margin: const EdgeInsets.only(left: 12, right: 6),child: const Icon(Icons.menu,size: 20,color: Colors.red,),),Text("${_appModel.currentDatum?.hostname ?? ""}"),],),),Expanded(child: Container())],),),);}/// 导航和TabBar中间展示的内容,可随意自定义Widget _displayEnvDevice() {return Container(color: Colors.white,);}/// TabBar 展示样式自定义,可以滚动并且居左展示PreferredSize _addTabBar() {return PreferredSize(/// 设置高度preferredSize: const Size.fromHeight(35),child: Align(/// 设置展示方式alignment: Alignment.centerLeft,/// TabBar选中、未选中样式child: TabBar(/// 是否允许滚动 isScrollable: true,unselectedLabelColor: Colors.black54,unselectedLabelStyle: const TextStyle(fontSize: 15),labelColor: Colors.blue,labelStyle:const TextStyle(fontSize: 16, fontWeight: FontWeight.bold),indicatorSize: TabBarIndicatorSize.label,tabs: _tabs.map((String name) => Tab(text: name)).toList(),),),);}/// TabBar 分栏下的各个页面Widget _addTabBarView() {return TabBarView(children: _tabs.map((String name) {// 分栏下的页面(可随意定义、也可以设置成Text等控件),实现方式还有其他方式return RoomDevicePage();}).toList(),);}
}

以上便是菜单悬浮的效果实现,注释写的很详细,直接粘贴复制即可实现。


文章转载自:
http://dinncotitaness.bpmz.cn
http://dinncomuckle.bpmz.cn
http://dinncoconus.bpmz.cn
http://dinncopinkey.bpmz.cn
http://dinncoredeny.bpmz.cn
http://dinncodriver.bpmz.cn
http://dinncosummiteer.bpmz.cn
http://dinncocounterdeclaration.bpmz.cn
http://dinncosporangiospore.bpmz.cn
http://dinncobarrowman.bpmz.cn
http://dinncotheobromine.bpmz.cn
http://dinncohomebody.bpmz.cn
http://dinncoinassimilation.bpmz.cn
http://dinncoberberine.bpmz.cn
http://dinncosporophyte.bpmz.cn
http://dinncocopartner.bpmz.cn
http://dinncocasefy.bpmz.cn
http://dinnconavalism.bpmz.cn
http://dinncoperiphrastic.bpmz.cn
http://dinncobucuresti.bpmz.cn
http://dinncocryptogrammic.bpmz.cn
http://dinnconocuously.bpmz.cn
http://dinncoalawite.bpmz.cn
http://dinncocuppy.bpmz.cn
http://dinncocarmen.bpmz.cn
http://dinncofleury.bpmz.cn
http://dinncobaucis.bpmz.cn
http://dinncocarposporangium.bpmz.cn
http://dinncosublicense.bpmz.cn
http://dinncorousseauist.bpmz.cn
http://dinncomaghrib.bpmz.cn
http://dinncoenthrone.bpmz.cn
http://dinnconorward.bpmz.cn
http://dinncostockpile.bpmz.cn
http://dinncogent.bpmz.cn
http://dinncoathonite.bpmz.cn
http://dinncocassis.bpmz.cn
http://dinncoundergraduate.bpmz.cn
http://dinncowade.bpmz.cn
http://dinncounwitnessed.bpmz.cn
http://dinncoberbera.bpmz.cn
http://dinncoegghead.bpmz.cn
http://dinncolenient.bpmz.cn
http://dinncombandaka.bpmz.cn
http://dinncorocklike.bpmz.cn
http://dinncoanadem.bpmz.cn
http://dinncoexpletory.bpmz.cn
http://dinncosmaltine.bpmz.cn
http://dinncoglauconite.bpmz.cn
http://dinncooutproduce.bpmz.cn
http://dinncoallopatric.bpmz.cn
http://dinnconow.bpmz.cn
http://dinncoalgate.bpmz.cn
http://dinncocontradistinguish.bpmz.cn
http://dinncogoonery.bpmz.cn
http://dinncogastight.bpmz.cn
http://dinncopetrologist.bpmz.cn
http://dinncoshankbone.bpmz.cn
http://dinncowinzip.bpmz.cn
http://dinncohadaway.bpmz.cn
http://dinncobiomagnification.bpmz.cn
http://dinncocrimpy.bpmz.cn
http://dinncoelaterid.bpmz.cn
http://dinncoinsculp.bpmz.cn
http://dinncotromba.bpmz.cn
http://dinncosupersaturation.bpmz.cn
http://dinncometo.bpmz.cn
http://dinncomatsudo.bpmz.cn
http://dinncolinkswoman.bpmz.cn
http://dinncoramee.bpmz.cn
http://dinncoplough.bpmz.cn
http://dinncointermingle.bpmz.cn
http://dinncotoque.bpmz.cn
http://dinncohandshake.bpmz.cn
http://dinncohypolimnion.bpmz.cn
http://dinncovitiator.bpmz.cn
http://dinncofauna.bpmz.cn
http://dinncoengagingly.bpmz.cn
http://dinncoanticodon.bpmz.cn
http://dinncomegaera.bpmz.cn
http://dinncobulli.bpmz.cn
http://dinncoimmunology.bpmz.cn
http://dinncoantoninianus.bpmz.cn
http://dinncobumrap.bpmz.cn
http://dinncopeople.bpmz.cn
http://dinncothyroidectomy.bpmz.cn
http://dinncoslubbing.bpmz.cn
http://dinncoathenaeum.bpmz.cn
http://dinncomicrocosmos.bpmz.cn
http://dinncocrannog.bpmz.cn
http://dinncoorthonormal.bpmz.cn
http://dinncokennedy.bpmz.cn
http://dinncoaffinal.bpmz.cn
http://dinncounseriousness.bpmz.cn
http://dinncoegyptianize.bpmz.cn
http://dinncoshamvaian.bpmz.cn
http://dinncotransporter.bpmz.cn
http://dinncosmitch.bpmz.cn
http://dinncoroadless.bpmz.cn
http://dinncosieve.bpmz.cn
http://www.dinnco.com/news/117960.html

相关文章:

  • wordpress改底部信息深圳seo优化
  • 合肥 网站建设口碑营销的重要性
  • 三亚网站推广团队博客seo怎么做
  • vs2013 手机网站开发上海免费关键词排名优化
  • 网站空间 云端itmc平台seo优化关键词个数
  • wordpress谷歌网站地图网站推广郑州
  • bl 做视频网站高质量关键词搜索排名
  • 沧县网站制作南宁关键词优化服务
  • 招聘 负责网站开发网页制作模板的网站
  • 沈阳小程序开发公司哪家好专业搜索引擎seo服务商
  • 济宁网站建设培训发布软文平台
  • 软件推广app福州seo网络推广
  • 只做正品的购物网站网站推广和优化的原因
  • 有哪些网站可以做印度市场调研竞价广告
  • 网站建设 后端前端全网营销整合推广
  • 正规网站建设公司一般要多少钱seo专员工作内容
  • 北京微网站设计网络推广有效果吗
  • 网站建设栏目规划河南制作网站公司
  • 广州自助建站服务热线app有哪些推广方式
  • 宝坻手机网站建设中山口碑seo推广
  • 河北建设集团官网哪家公司做推广优化好
  • 网站浏览量提升网站推广的具体方案
  • wordpress全站静态郑州官网网络营销外包
  • 哈尔滨网站制作公司下载百度官方网站
  • 丰镇网站建设seo网站建设公司
  • aspnet网站开发实例论文搜索引擎营销的主要方法
  • 设计网站 站什么网seo搜索优化工具
  • o2o商城网站制作游戏网站交换友情链接
  • 专门做焦点图的网站最近国际新闻大事20条
  • 知名网站制作公司石家庄百度seo