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

郑州网站运营专业乐云seo郑州seo外包顾问热狗

郑州网站运营专业乐云seo,郑州seo外包顾问热狗,阜阳集团网站建设,青山seo排名公司。 在开发中经常遇到首页的分类入口#xff0c;如美团的美食团购、打车等入口#xff0c;左右切换还可以分页更多展示。 一、使用flutter_swiper_null_safety 在pubspec.yaml引入 # 轮播图flutter_swiper_null_safety: ^1.0.2二、实现swiper分页代码 由于我这里按照一页8… 。 在开发中经常遇到首页的分类入口如美团的美食团购、打车等入口左右切换还可以分页更多展示。 一、使用flutter_swiper_null_safety 在pubspec.yaml引入 # 轮播图flutter_swiper_null_safety: ^1.0.2二、实现swiper分页代码 由于我这里按照一页8条展示两行四列展示格式。 当列表list传入的控件时候一共的页数为 int getSwiperPageNumber() {int allLength widget.list.length;int aPageNum getSwiperOnePageNumber();if (allLength % aPageNum 0) {return (allLength / aPageNum).toInt();}return (allLength / aPageNum).toInt() 1;}通过列表一页数量计算每一页应该展示多少个按钮。 List getSwiperPagerItems(int pagerIndex) {List pagerItems [];int allLength widget.list.length;int aPageNum getSwiperOnePageNumber();int start pagerIndex * aPageNum;int end (pagerIndex 1) * aPageNum;if (end allLength) {end allLength;}pagerItems widget.list.sublist(start, end);return pagerItems;}一共pages的列表 int pagerNumber getSwiperPageNumber();for (int index 0; index pagerNumber; index) {CategorySwiperPagerItem swiperPagerItem CategorySwiperPagerItem();swiperPagerItem.pagerIndex index;swiperPagerItem.pagerItems getSwiperPagerItems(index);swiperPagers.add(swiperPagerItem);}通过使用flutter_swiper_null_safety来显示 Swiper(// 横向scrollDirection: Axis.horizontal,// 布局构建itemBuilder: (BuildContext context, int index) {CategorySwiperPagerItem swiperPagerItem swiperPagers[index];return HomeCategoryPager(pagerIndex: swiperPagerItem.pagerIndex,pageItems: swiperPagerItem.pagerItems,width: itemWidth,height: itemHeight,containerHeight: showHeight,containerWidth: width,);},//条目个数itemCount: swiperPagers.length,// 自动翻页autoplay: false,// pagination: _buildSwiperPagination(),// pagination: _buildNumSwiperPagination(),//点击事件// onTap: (index) {// LoggerManager().debug( 点击 index.toString());// },// 相邻子条目视窗比例viewportFraction: 1,// 用户进行操作时停止自动翻页autoplayDisableOnInteraction: true,// 无限轮播loop: false,//当前条目的缩放比例scale: 1,),实现比较简单 完整代码如下 import package:flutter/material.dart; import package:flutter_screenutil/flutter_screenutil.dart; import package:flutter_swiper_null_safety/flutter_swiper_null_safety.dart; import package:flutter_app_dfaceintl/config/resource_manager.dart; import package:flutter_app_dfaceintl/utils/color_util.dart; import package:flutter_app_dfaceintl/widget/common/show_gesture_container.dart; import package:one_context/one_context.dart; import package:flutter_app_dfaceintl/config/logger_manager.dart;class CategorySwiperPagerItem {int pagerIndex 0;List pagerItems []; }class HomeCategoryWidget extends StatefulWidget {const HomeCategoryWidget({Key? key,required this.rowNumber,required this.numberOfPerRow,required this.list,required this.screenWidth,}) : super(key: key);// 多少行final int rowNumber;// 一行几个final int numberOfPerRow;final List list;final double screenWidth;overrideStateHomeCategoryWidget createState() _HomeCategoryWidgetState(); }class _HomeCategoryWidgetState extends StateHomeCategoryWidget {double showHeight 0.0;double containVPadding 5.0;double containHPadding 10.0;ListCategorySwiperPagerItem swiperPagers [];bool showPagination false;overridevoid initState() {// TODO: implement initStatedouble containerHeight getContainerMaxHeight(widget.screenWidth);showHeight containerHeight 2 * containVPadding;int pagerNumber getSwiperPageNumber();for (int index 0; index pagerNumber; index) {CategorySwiperPagerItem swiperPagerItem CategorySwiperPagerItem();swiperPagerItem.pagerIndex index;swiperPagerItem.pagerItems getSwiperPagerItems(index);swiperPagers.add(swiperPagerItem);}if (swiperPagers.length 1) {showPagination true;}super.initState();}overridevoid dispose() {// TODO: implement disposesuper.dispose();}overrideWidget build(BuildContext context) {double width widget.screenWidth;double itemWidth (width - 2 * containHPadding) / widget.numberOfPerRow;double itemHeight itemWidth;return Container(width: width,height: showHeight,margin: EdgeInsets.symmetric(vertical: 5.0),padding: EdgeInsets.symmetric(vertical: containVPadding,horizontal: containHPadding,),color: Colors.white,child: Swiper(// 横向scrollDirection: Axis.horizontal,// 布局构建itemBuilder: (BuildContext context, int index) {CategorySwiperPagerItem swiperPagerItem swiperPagers[index];return HomeCategoryPager(pagerIndex: swiperPagerItem.pagerIndex,pageItems: swiperPagerItem.pagerItems,width: itemWidth,height: itemHeight,containerHeight: showHeight,containerWidth: width,);},//条目个数itemCount: swiperPagers.length,// 自动翻页autoplay: false,// pagination: _buildSwiperPagination(),// pagination: _buildNumSwiperPagination(),//点击事件// onTap: (index) {// LoggerManager().debug( 点击 index.toString());// },// 相邻子条目视窗比例viewportFraction: 1,// 用户进行操作时停止自动翻页autoplayDisableOnInteraction: true,// 无限轮播loop: false,//当前条目的缩放比例scale: 1,),);}int getSwiperOnePageNumber() {return widget.numberOfPerRow * widget.rowNumber;}int getSwiperPageNumber() {int allLength widget.list.length;int aPageNum getSwiperOnePageNumber();if (allLength % aPageNum 0) {return (allLength / aPageNum).toInt();}return (allLength / aPageNum).toInt() 1;}List getSwiperPagerItems(int pagerIndex) {List pagerItems [];int allLength widget.list.length;int aPageNum getSwiperOnePageNumber();int start pagerIndex * aPageNum;int end (pagerIndex 1) * aPageNum;if (end allLength) {end allLength;}pagerItems widget.list.sublist(start, end);return pagerItems;}double getContainerMaxHeight(double screenWidth) {double width screenWidth;double itemSize (width - 2 * containHPadding) / widget.numberOfPerRow;double maxHeight itemSize * widget.rowNumber;int allLength widget.list.length;if (allLength widget.numberOfPerRow) {maxHeight itemSize;}return maxHeight;} }class HomeCategoryPager extends StatelessWidget {const HomeCategoryPager({Key? key,required this.pagerIndex,required this.pageItems,required this.width,required this.height,this.containerWidth,this.containerHeight,}) : super(key: key);final int pagerIndex;final List pageItems;final double width;final double height;final double? containerWidth;final double? containerHeight;overrideWidget build(BuildContext context) {return Container(width: containerWidth,height: containerHeight,child: Wrap(children: pageItems.map((e) HomeCategoryItem(width: width,height: height,)).toList(),),);} }class HomeCategoryItem extends StatelessWidget {const HomeCategoryItem({Key? key,required this.width,required this.height,}) : super(key: key);final double width;final double height;overrideWidget build(BuildContext context) {return ShowGestureContainer(padding: EdgeInsets.symmetric(vertical: 5.0, horizontal: 5.0),width: width,height: height,highlightedColor: ColorUtil.hexColor(0xf0f0f0),onPressed: () {LoggerManager().debug(ShowGestureContainer);},child: Column(mainAxisAlignment: MainAxisAlignment.center,crossAxisAlignment: CrossAxisAlignment.center,children: [buildIcon(),Padding(padding: EdgeInsets.only(top: 5.0),child: buildTitle(),),],),);}Widget buildTitle() {return Text(栏目,textAlign: TextAlign.left,maxLines: 2,overflow: TextOverflow.ellipsis,softWrap: true,style: TextStyle(fontSize: 12,fontWeight: FontWeight.w500,fontStyle: FontStyle.normal,color: ColorUtil.hexColor(0x444444),decoration: TextDecoration.none,),);}Widget buildIcon() {return Icon(Icons.access_alarm,size: 32.0,color: Colors.brown,);} }三、小结 flutter开发实战-实现首页分类目录入口切换功能。Swiper实现如美团的美食团购、打车等入口左右切换还可以分页更多展示。 学习记录每天不停进步。
http://www.hkea.cn/news/14447182/

相关文章:

  • 湖南网站制作哪家好iis 多网站
  • 国外可以做网站盈利模式有哪些自己做网赌网站
  • 安 网站建设重庆网站建设 公司
  • 网站推广方式百度云帝国做网站的步骤
  • 做网站公司联系方式页面个人网银登录入口
  • 站长推广工具seo搜索引擎优化原理
  • 做网站服务器哪个好企业网站建设开发费用
  • 网站建设费是什么化妆品企业网站案例大全
  • 编程网站ide做的比较好的重庆忠县网站建设公司哪家好
  • 母婴 网站 策划建站之星模板下载网站
  • 企业网站建设服务好工业互联网六大应用场景
  • 网站开发建设需要什么wordpress书签插件
  • 做翻译兼职的网站是哪个3d效果图制作软件
  • 中国有哪些网站可以做兼职滁州网站建设hi444
  • 重庆市建设医院网站网站开发那家好
  • 网店推广的目的wordpress的seo收件箱
  • 放单网站自己做网站 什么
  • 建筑公司网站起名国外免费网站空间
  • 建设网站 备案客村网站建设
  • 网站集约化建设工作讲话wordpress免费博客主题
  • 网站标题字符专业的画册设计网站
  • 网站备案现状做打鱼网站
  • 网站开发工程师试用期asp.net网站管理工具
  • 房产销售网站设计上海到北京专线物流
  • 淮安市广德育建设网站wordpress 能做哪些
  • 企业管理网站的来历wordpress 页面排序
  • 长沙设备建站按效果付费263企业邮箱后缀是什么
  • 装修设计网站哪个最好山东建设官方网站
  • 个人做同城网站赚钱吗科技设计网站有哪些
  • 非官方网站建设免费网站后台模版